问题描述
关键字'table'附近的语法不正确。
protected void Button2_Click(object sender,EventArgs e)
{
//字符串查询;
string str =数据源= HIMANSHU- PC;初始目录= new1;集成安全性=真;
SqlConnection con = new SqlConnection(str);
con.Open();
string query =insert into table dbinfo values('+ TextBox1.Text +','+ TextBox2.Text +');
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
con.Close();
}
Incorrect syntax near the keyword 'table'.
protected void Button2_Click(object sender, EventArgs e)
{
// string query;
string str = "Data Source=HIMANSHU-PC;Initial Catalog=new1;Integrated Security=True";
SqlConnection con = new SqlConnection(str);
con.Open();
string query = "insert into table dbinfo values('" + TextBox1.Text + "','" + TextBox2.Text + "')";
SqlCommand cmd = new SqlCommand(query,con);
cmd.ExecuteNonQuery();
con.Close();
}
推荐答案
这篇关于当我尝试存储用户名和城市时,它显示错误(db是SQL SERVER2008)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!