向Access里插入值的问题
表Table里有4列:A、B、C、D,其中A为自动编号列,我用向SQL插入的方式写Sql语句
insert into Table values( ' "+ B + " ', ' "+ C + " ', ' "+ D + " ')
报错:查询值的数目与目标字段中的数目不同
向Access添加数据的时候到底该怎么做啊?
请高手赐教
[解决办法]
楼上正解
[解决办法]
insert into Table(B,C,D) values( ' "+ B + " ', ' "+ C + " ', ' "+ D + " ')
还要注意字段类型,引号不同
[解决办法]
OleDbCommand cmd = new OleDbCommand( "insert into bbs(name,people,tel,text) values( ' "+ name + " ', ' "+ peo + " ', ' "+ tel + " ', ' "+ txt + " ') ",con);
改成:
OleDbCommand cmd = new OleDbCommand( "insert into bbs([name],[people],[tel],[text]) values( ' "+ name + " ', ' "+ peo + " ', ' "+ tel + " ', ' "+ txt + " ') ",con);