西点军校学雷锋:INSERT语句,急,在线等

来源:百度文库 编辑:高校问答 时间:2024/04/28 22:59:44
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()+"'";
strsql+=",'"+TextBox5.Text.ToString()+"')";

strsql+=",'"+TextBox3.Text.ToString()+"')";
strsql+=",'"+TextBox4.Text.ToString()+"')";
strsql+=",'"+TextBox5.Text.ToString()+"')";
怎么这么多括号???低级错误.