i am making a search box in visual studio that looks through a csv file as a database, the sql query works but not fully. if i put the sql database as:
SELECT Number_Plate, Regstered_Keeper, Make, Model, Year_Of_Make, Colour, Engine_Size, Transmission, Fuel_Type FROM 'tabledata.csv' WHERE Number_Plate = 'B9BOL'
it works but only looks through the specific number plate but my code is:
"SELECT Number_Plate, Regstered_Keeper, Make, Model, Year_Of_Make, Colour, Engine_Size, Transmission, Fuel_Type FROM` `'tabledata.csv' WHERE Number_Plate = "+ textBox1.Text
and that does not wok and it displays the following error when excuting:
ERROR [42000] [Microsoft][ODBC Text Driver] Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
in visual studio the code is as follows:
private void Show_Click(object sender, EventArgs e)
{
Data.Items.Clear();
var ta = new CarsDataSetTableAdapters.tabledata_csvTa…
Make.DataSource = ta.GetDataByPlate();
Make.DisplayMember = "Make";
}
Looks like you're missing some quotes from around your where clause:
"SELECT Number_Plate,
Regstered_Keeper,
Make,
Model,
Year_Of_Make,
Colour,
Engine_Size,
Transmission,
Fuel_Type
FROM 'tabledata.csv'
WHERE Number_Plate = '"+ textBox1.Text + "'"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.