在Excel表格中插入数据时插入语句中的语法错误
我在运行时在我的Windows窗体中导入Excel表,通过表单添加一些数据。 当我将这些数据重新插入时,它会提供:
插入到语句中的语法错误
这是我正在使用的查询:
string qry = string.Format("Insert into [Sheet1$] (username,password) values('"+uname+"','"+pwd+"')");
试试这个,即添加[]列:
string qry = string.Format("Insert into [Sheet1$] ([username],[password]) values('"+uname+"','"+pwd+"')");
也尝试没有string.Format()
代码是正确的,有我使用的Excel文件的权限问题,我没有完全控制该Excel,我改变了权限和代码开始工作。