INSERT语句,急,在线等

来源:百度知道 编辑:UC知道 时间:2024/05/24 17:41:07
string strsql;
strsql="insert into userinfo(wendu,shidu,jianceshijian,chixushijian,bianhuadu)values("; strsql+=",'"+TextBox1.Text.ToString()+"'";
strsql+=",'"+TextBox2.Text.ToString()+"'";
strsql+=",'"+TextBox3.Text.ToString()+"')";
strsql+=",'"+TextBox4.Text.ToString()+"')";
strsql+=",'"+TextBox5.Text.ToString()+"')";
SqlCommand com = new SqlCommand(strsql,con);
SqlDataReader rd=com.ExecuteReader();
this.DataGrid1.DataBind();
为什么报错说
"SqlCommand com = new SqlCommand(strsql,con);"
逗号附近有语法错误?是什么错误?
用.NET做的

strsql="insert into userinfo(wendu,shidu,jianceshijian,chixushijian,bianhuadu)values("; strsql+=",'"+TextBox1.Text.ToString()+"'";
strsql+=",'"+TextBox2.Text.ToString()+"'";
strsql+=",'"+TextBox3.Text.ToString()+"')";
strsql+=",'"+TextBox4.Text.ToString()+"')";
strsql+=",'"+TextBox5.Text.ToString()+"')";
wendu,shidu,jianceshijian,chixushijian,bianhuadu 共 5 个列,值也是5个,那麼你从 value( 这里开始,后边那个 "," 号是不是多於的呢?括号也有错误,修正后像这样:
strsql="insert into userinfo(wendu,shidu,jianceshijian,chixushijian,bianhuadu)values("; strsql+="'"+TextBox1.Text.ToString()+"'";
strsql+=",'"+TextBox2.Text.ToString()+"'";
strsql+=",'"+TextBox3.Text.ToString()+"'";
strsql+=",'"+TextBox4.Text.ToString()+&q