我正在运行时在 Windows 窗体中导入 Excel 工作表,通过窗体向其中添加一些数据。当我将该数据插入回来时,它会给出:
syntax error in insert into statement
这是我正在使用的查询:
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()
关于c# - 在 Excel 工作表中插入数据时 Insert into 语句中出现语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13945343/