cmd.ExecuteNonQuery();第一行‘=’附近有语法错误,错在哪里了??
publicvoidupdataCustomers(stringCustomerID,stringCompanyName,stringContactName,string...
public void updataCustomers(string CustomerID,string CompanyName,string ContactName,string Address)
{
SqlConnection cn=new SqlConnection ("server=localhost;database=NorthWind;user=mjc;password=123;");
SqlCommand cmd=new SqlCommand("updata Customers set CompanyName='"+ CompanyName+"',ContactName='"+ContactName+"',Address="'+Address+"'where CustomerID='"+CustomerID+""",cn);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
} 展开
{
SqlConnection cn=new SqlConnection ("server=localhost;database=NorthWind;user=mjc;password=123;");
SqlCommand cmd=new SqlCommand("updata Customers set CompanyName='"+ CompanyName+"',ContactName='"+ContactName+"',Address="'+Address+"'where CustomerID='"+CustomerID+""",cn);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
} 展开
1个回答
展开全部
SqlCommand cmd=new SqlCommand("updata Customers set CompanyName='"+ CompanyName+"',ContactName='"+ContactName+"',Address="'+Address+"'where CustomerID='"+CustomerID+""",cn);////错误updata->update
正确为:
SqlCommand cmd=new SqlCommand("update Customers set CompanyName='"+ CompanyName+"',ContactName='"+ContactName+"',Address="'+Address+"'where CustomerID='"+CustomerID+""",cn);////错误updata->update
正确为:
SqlCommand cmd=new SqlCommand("update Customers set CompanyName='"+ CompanyName+"',ContactName='"+ContactName+"',Address="'+Address+"'where CustomerID='"+CustomerID+""",cn);////错误updata->update
追问
还是不对,出现了第一行:‘Laurence’附近有语法错误。字符串‘’之前有未闭合的引号。
追答
SqlCommand cmd=new SqlCommand("update Customers set CompanyName='"+ CompanyName+"',ContactName='"+ContactName+"',Address='"+Address+"' where CustomerID='"+CustomerID+"'",cn);////错误updata->update(标点符号问题 认真查看下)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询