string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
strConnection += @"Data Source=E:\product.mdb"; OleDbConnection objConnection = new OleDbConnection(strConnection);
objConnection.Open();
string strSQL = "DELETE * FROM Product WHERE productName='" + this.TextBox3.Text + " '";
OleDbCommand cmd = new OleDbCommand(strSQL, objConnection); cmd.ExecuteNonQuery();
cmd.Connection.Close();
objConnection.Close();
为什么这样数据还没有删除成功呢,急啊
strConnection += @"Data Source=E:\product.mdb"; OleDbConnection objConnection = new OleDbConnection(strConnection);
objConnection.Open();
string strSQL = "DELETE * FROM Product WHERE productName='" + this.TextBox3.Text + " '";
OleDbCommand cmd = new OleDbCommand(strSQL, objConnection); cmd.ExecuteNonQuery();
cmd.Connection.Close();
objConnection.Close();
为什么这样数据还没有删除成功呢,急啊
string strSQL = "DELETE * FROM Product WHERE productName='" + this.TextBox3.Text + " '"; 改
string strSQL = "DELETE Product WHERE productName='" + this.TextBox3.Text + " '";
DELETE Product WHERE productName='" + this.TextBox3.Text + " 'ACCESS 没用过 ,估计肯定不是你这样写的
大概是这样
DELETE FROM Product WHERE productName='" + this.TextBox3.Text + " '
DELETE Product WHERE productName='" + this.TextBox3.Text + " '
看一下strSQL的值是多少
可能是this.TextBox3.Text内容前后包含有空格删除时,最好使用主键字段做为WHERE条件
你先断点看看生成字串是什么?
然后再看看能不能在查询分析器中执行