关于数据库操作的问题,请高手指教,看看这两名有什么不同?
以下两段实现同样的功能:都是向数据库中插入记录,只是数据库不同,一个是SQL server 2000,一个是ACCESS,操作语句完全一样,为什么上句运行正常,而下句却报错?(数据库字段完全一致)
str = "INSERT INTO Record(姓名, 职务, 单位) VALUES ( '22','22','22')" ;
sqlInsertCommand1=new System.Data.SqlClient.SqlCommand(str,sqlConnection1);
sqlConnection1.Open ( ) ;
try
{
sqlInsertCommand1.ExecuteNonQuery();;
}
catch(Exception ep)
{
MessageBox.Show ( ep.Message ) ;
return;
}
finally
{
sqlConnection1.Close ( ) ;
}
str = "INSERT INTO Record(姓名, 职务, 单位) VALUES ( '22','22','22')" ;
oleDbInsertCommand1=new System.Data.OleDb.OleDbCommand(str,oleDbConnection1);
oleDbConnection1.Open ( ) ;
try
{
oleDbInsertCommand1.ExecuteNonQuery();;
}
catch(Exception ep)
{
MessageBox.Show ( ep.Message ) ; //捕获错误,ep.Message的值为"未知"?????????
return;
}
finally
{
oleDbConnection1.Close ( ) ;
}