c#,'( ' 附近有语法错误.

private void button1_Click(object sender, EventArgs e)
{
SqlConnection c = new SqlConnection(Properties .Settings .Default .mainConnectionString );
c.Open();

string s = "insert into menu(编号,名称,价目(元))values('"+textBox1 .Text .ToString ()+"'+'"+textBox2 .Text .ToString ()+"'+'"+textBox3 .Text .ToString ()+"')";
SqlCommand cm = new SqlCommand(s,c);
//cm.CommandText = s;
//cm.Connection = c;
int q= cm.ExecuteNonQuery();
if (q == 1) { MessageBox.Show("添加成功"); }
else { MessageBox.Show("添加失败"); }
c.Close();

}

温温酱
浏览 566回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP