0

我正在 Visual Studio 中创建一个搜索框,将 csv 文件作为数据库进行查看,sql 查询有效但不完全。如果我将 sql 数据库设置为:

SELECT Number_Plate, Regstered_Keeper, Make, Model, Year_Of_Make, Colour, Engine_Size, Transmission, Fuel_Type FROM 'tabledata.csv' WHERE Number_Plate = 'B9BOL'

它可以工作,但只能查看特定的车牌,但我的代码是:

"SELECT Number_Plate, Regstered_Keeper, Make, Model, Year_Of_Make, Colour, Engine_Size, Transmission, Fuel_Type FROM` `'tabledata.csv' WHERE Number_Plate = "+ textBox1.Text

这不起作用,它在执行时显示以下错误:

ERROR [42000] [Microsoft][ODBC Text Driver] Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.

在visual studio中,代码如下:

private void Show_Click(object sender, EventArgs e)
 {
 Data.Items.Clear();
 var ta = new CarsDataSetTableAdapters.tabledata_csvTa…

Make.DataSource = ta.GetDataByPlate();
 Make.DisplayMember = "Make";
 }
4

1 回答 1

0

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 + "'"
于 2013-02-04T21:21:25.173 回答