private void button4_Click_1(object sender, EventArgs e)
{
string s = textBox1.Text;
SqlCeConnection conn = new SqlCeConnection(@"Data Source=D:\Desktop\DB2\DB2\Database1.sdf");
try
{
conn.Open();
SqlCeCommand cmd = new SqlCeCommand(" update Kambariai set Kliento ID = Kliento ID + s Where Kliento ID = 0 ", conn);
cmd.ExecuteNonQuery();
toolStripStatusLabel1.Text = "Duomenys įrašyti";
conn.Close();
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
}Datatable模式显示列存在,但我仍然得到错误--列名无效--也许我忘了写什么--请帮助我:)我要做的是从textbox1.Text中获取文本,然后更新它datatable值,其中库仑名为Kliento ID,值为0。
http://i.stack.imgur.com/ZM4LN.jpg

发布于 2014-05-11 10:20:56
mysql)
使用backticks() around the field name. Try this way: SqlCeCommand cmd = new SqlCeCommand(" update Kambariai setKliento ID=Kliento ID+ "+s+" WhereKliento ID‘=0 ",conn);
侧注:回标将用于表和列标识符,但只有在标识符是MySQL保留关键字时才有必要,或者当标识符包含空白字符或字符超出有限集时,通常建议尽可能避免使用保留关键字作为列或表标识符,以避免引用问题。在以下情况下,背蜱是必要的:
选择id,my name,another field,field,with,comma
sql server)
试一试[]:
SqlCeCommand cmd =新SqlCeCommand(“update Kambariai = Kliento + "+s+”其中Kliento =0,conn);发布于 2014-05-11 10:46:53
试试这个:
SqlCeCommand cmd = new SqlCeCommand("update Kambariai set [Kliento ID] = [Kliento ID] + " + s + " Where [Kliento ID] = 0", conn);https://stackoverflow.com/questions/23591403
复制相似问题