I
Ivan Sammut
Hi,
I created an access database and I am using ado.net to access it. Now I am
trying to create an update statment but I am having some error when so
fields are empty.
Here is my statment which read a set of textboxes from a screen and tries to
save 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 I
empty one of the textboxes the system gives an error. Any idea?
I created an access database and I am using ado.net to access it. Now I am
trying to create an update statment but I am having some error when so
fields are empty.
Here is my statment which read a set of textboxes from a screen and tries to
save 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 I
empty one of the textboxes the system gives an error. Any idea?