下面C#语句无法运行!运行时提示说 sqlcommand.ExecuteNonQuery();有错望大神帮助! 15

protectedvoidButton1_Click(objectsender,EventArgse){intn=0;n++;this.Insert(n,this.nam... protected void Button1_Click(object sender, EventArgs e)
{
int n = 0; n++;
this.Insert(n, this.name.Text, this.address.Text, this.password.Text, this.bank.Text, this.account.Text, this.mgr.Text);
}

protected void Insert(int n, string name, string address, string password, string bank, string account, string mgr)
{
using (SqlConnection sqlconnection = new SqlConnection(ConfigurationManager.ConnectionStrings["conStr"].ToString()))
{
string sql = "inset into Client(Client_name,Client_adderss,Client_password,Client_bank,Client_account,Client_mgr) values(" + name + "," + address + "," + password + "," + bank + "," + account + "," + mgr + "')";
sqlconnection.Open();
SqlCommand sqlcommand = new SqlCommand(sql, sqlconnection);
sqlcommand.ExecuteNonQuery();
Response.Write("<script>alert('Insert ok!');</script>");
}

}
展开
 我来答
匿名用户
2015-12-13
展开全部
是insert不是inset,另外文本型值外面要加一对单引号。

改成:
string sql = "insert into Client(Client_name,Client_adderss,Client_password,Client_bank,Client_account,Client_mgr) values('" + name + "','" + address + "','" + password + "','" + bank + "','" + account + "','" + mgr + "')";
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式