string sqlStatement="Update Customers set "+
"CompanyName='"+txtCompanyName.Text+"',"+
"ContactName='"+txtContactName.Text+"',"+
"ContactTitle='"+txtContactTitle.Text+"',"+
"Address='"+txtCity.Text+"',"+
"City='"+txtCity.Text+"',"+
"Region='"+txtRegion.Text+"',"+
"PostalCode='"+txtPost.Text+"',"+
"Country='"+txtCountry.Text+"',"+
"Phone='"+txtPhone.Text+"',"+
"Fax='"+txtFax.Text="'"+
"where CustomerID='"+cbxCusID.Text+"'";在第二行出现错误如下
G:\Mr5工作室\C#\CustomersApp\Form1.cs(537): 赋值号左边必须是变量、属性或索引器我看不出错在哪里,哪位高人能否指点,在线等
"CompanyName='"+txtCompanyName.Text+"',"+
"ContactName='"+txtContactName.Text+"',"+
"ContactTitle='"+txtContactTitle.Text+"',"+
"Address='"+txtCity.Text+"',"+
"City='"+txtCity.Text+"',"+
"Region='"+txtRegion.Text+"',"+
"PostalCode='"+txtPost.Text+"',"+
"Country='"+txtCountry.Text+"',"+
"Phone='"+txtPhone.Text+"',"+
"Fax='"+txtFax.Text="'"+
"where CustomerID='"+cbxCusID.Text+"'";在第二行出现错误如下
G:\Mr5工作室\C#\CustomersApp\Form1.cs(537): 赋值号左边必须是变量、属性或索引器我看不出错在哪里,哪位高人能否指点,在线等
"CompanyName='"+txtCompanyName.Text+"',"+
~~~~~~~~~~~~~~~~~~~~~~
"ContactName='"+txtContactName.Text+"',"+
"ContactTitle='"+txtContactTitle.Text+"',"+
"Address='"+txtCity.Text+"',"+
"City='"+txtCity.Text+"',"+
"Region='"+txtRegion.Text+"',"+
"PostalCode='"+txtPost.Text+"',"+
"Country='"+txtCountry.Text+"',"+
"Phone='"+txtPhone.Text+"',"+
"Fax='"+txtFax.Text="',"+
"where CustomerID='"+cbxCusID.Text+"'";
赋值号左边必须是变量、属性或索引器
我加上逗号了,还是错,是在第二行.谢谢请再替我看看
"CompanyName='"+txtCompanyName.Text+"',"+
~~~~~~~~~~~~~~~~~~~
"ContactName='"+txtContactName.Text+"',"+
"ContactTitle='"+txtContactTitle.Text+"',"+
"Address='"+txtCity.Text+"',"+
"City='"+txtCity.Text+"',"+
"Region='"+txtRegion.Text+"',"+
"PostalCode='"+txtPost.Text+"',"+
"Country='"+txtCountry.Text+"',"+
"Phone='"+txtPhone.Text+"',"+
"Fax='"+txtFax.Text="',"+
"where CustomerID='"+cbxCusID.Text+"'";刚才那个没有排版好,这个还行,请替我看看
如:string strCmd = "Update Customers set CompanyName=@txtCompanyName";//后面参数自己加
SqlCommand cmd = new SqlCommand(strCmd, Conn);
cmd.Prepare();cmd.Parameters.Add("@txtCompanyName", SqlDbType.VarChar, 50);
cmd.Parameters["@txtCompanyName"].Value = txtCompanyName.Text;cmd.ExecuteNonQuery();
"Fax='"+txtFax.Text="'"+
"where CustomerID='"+cbxCusID.Text+"'";还有要where前要有空格
可能应该是
。
"Fax='"+txtFax.Text"' "+
"where CustomerID='"+cbxCusID.Text+"'";
既然要帮忙为什么不帮到底?!建议楼主以后调试出错时直接将 错误信息 输入MSDN帮助文档搜索,
一般都有相应的编译错误信息可供参考