错误提示:System.Data.OleDb.OleDbException:“在 SQL 语句结尾之后找到字符。”
sqla = "INSERT INTO AttributeConfig (aa, bb, cc,dd,ee,ff) " +
"VALUES ('" + aa+ "', 'bb', 'cc','dd','ee','ff');select @@identity as AttributeID";
原因:access不支持多语句的,access只能单句查询.
修改成如下代码
sqla = "INSERT INTO AttributeConfig (aa, bb, cc,dd,ee,ff) " +
"VALUES ('" + aa+ "', 'bb', 'cc','dd','ee','ff')";
OleDbCommand cmda = new OleDbCommand(sqla, con);
cmda.ExecuteNonQuery();
cmda.CommandText = "select @@identity as AttributeID";
cmda.Parameters.Clear();
int idd = Convert.ToInt32(cmda.ExecuteScalar());