日期:2014-05-18  浏览次数:20895 次

谁给俺把SQL改成access 多谢
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
  {
  string sqlstr = "delete from tb_Member where id='" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
  sqlcon = new SqlConnection(strCon);
  sqlcom = new SqlCommand(sqlstr,sqlcon);
  sqlcon.Open();
  sqlcom.ExecuteNonQuery();
  sqlcon.Close();
  bind();
  }

------解决方案--------------------
using System.Data.SqlClient;
改为 using System.Data.OleDb;
SqlConnection 改为 OleDbConnection
SqlCommand 改为 OleDbCommand
------解决方案--------------------
using System.Data.OleDb;

OleDbConnection sqlcon;
OleDbCommand sqlcom;

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
string sqlstr = "delete from tb_Member where id='" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
sqlcon = new OleDbConnection(strCon);
sqlcom = new OleDbCommand(sqlstr,sqlcon);
sqlcon.Open();
sqlcom.ExecuteNonQuery();
sqlcon.Close();
bind();
}
------解决方案--------------------
就你这个代码而言不需要修改就能在access上运行。如ls所说。

但是你应该检查程序中是否有别的地方使用了sql方言、存储过程、视图、触发器、子查询等等access不支持的特性,如果有,就不要白花力气了。