本文介绍了ADO.NEt保存空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我创建了一个访问数据库,我正在使用ado.net来访问它。现在我是 试图创建一个更新语句,但是我有一些错误,所以 字段是空的。 这里是我的判断,从屏幕上读取一组文本框并尝试将保存起来。 string sSql; OleDbConnection conn = new OleDbConnection(Form1.Dbase); sSql =" Update Users Set"; sSql = sSql +" Usr_login = \"" + textBox1.Text.Trim()+" \"," ;; sSql = sSql +" Usr_name = \"" + textBox2.Text.Trim()+" \"," ;; sSql = sSql +" Usr_desg = \"" + textBox3.Text.Trim()+" \"," ;; sSql = sSql +" Usr_mail = \"" + textBox4.Text.Trim()+" \"," ;; sSql = sSql +" Usr_mobile = \"" + textBox5.Text +" \"," ;; sSql = sSql +" Usr_disb =" + checkBox2.Checked.ToString(); sSql = sSql +" Users.usr_code =" ;; sSql = sSql + pbusr; // //返回; conn.Open(); OleDbCommand cmd = new OleDbCommand(sSql,conn); cmd.ExecuteNonQuery(); conn .Close(); 这样可以正常工作,直到所有文本框都包含某些内容。一旦我打开其中一个文本框,系统就会出错。有什么想法吗?Hi,I created an access database and I am using ado.net to access it. Now I amtrying to create an update statment but I am having some error when sofields are empty.Here is my statment which read a set of textboxes from a screen and tries tosave them.string sSql;OleDbConnection conn = new OleDbConnection(Form1.Dbase);sSql = "Update Users Set ";sSql = sSql + "Usr_login = \"" + textBox1.Text.Trim() + "\",";sSql = sSql + "Usr_name = \"" + textBox2.Text.Trim() + "\",";sSql = sSql + "Usr_desg = \"" + textBox3.Text.Trim() + "\",";sSql = sSql + "Usr_mail = \"" + textBox4.Text.Trim() + "\",";sSql = sSql + "Usr_mobile = \"" + textBox5.Text + "\",";sSql = sSql + "Usr_disb = " + checkBox2.Checked.ToString();sSql = sSql + " where Users.usr_code =";sSql = sSql + pbusr;////return;conn.Open();OleDbCommand cmd = new OleDbCommand(sSql,conn);cmd.ExecuteNonQuery();conn.Close();This works fine until all the textboxes contain something. As soon as Iempty one of the textboxes the system gives an error. Any idea?推荐答案 尝试 尝试 我清空其中一个文本框,系统就会出错。有什么想法吗?I empty one of the textboxes the system gives an error. Any idea? 这篇关于ADO.NEt保存空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-12 09:24