.Net Access数据库更新问题

来源:百度知道 编辑:UC知道 时间:2024/06/12 23:11:26
protected void btnModifyRemark_Click(object sender, EventArgs e)
{
try
{
string strProductRemark = txtProductRemark.Text + "11111111";
string strProductname = lblProductName.Text;
string _conn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\\www\\hp\\data\\1.mdb";
OleDbConnection conn = new OleDbConnection(_conn);
conn.Open();
string strUpdateSql = "update ProductDetails set ProductName=" + strProductname + ",ProductDescription=" + strProductRemark + " where ProductID=" + Convert.ToInt32(m_strID);
OleDbCommand cmd = new OleDbCommand(strUpdateSql, conn);
cmd.ExecuteNonQuery();
conn.Close();
}
catch (Exception ex)
{
throw ex;
}

}
运行后提

string strUpdateSql = "update ProductDetails set ProductName='" + strProductname + "',ProductDescription='" + strProductRemark + "' where ProductID=" + Convert.ToInt32(m_strID);

你在SQL语句下面用Response.Write(strUpdateSql);把语句输出一下就知道哪个值是空的了