C#中怎么降多个文本框的数据存入SQL2005数据库
2个回答
展开全部
var s1 = txt1.Text;
var s2 = txt2.Text;
var s3 = txt3.Text;
var s4 = txt4.Text;
var s5 = txt5.Text;
var s6 = txt6.Text;
var s7 = txt7.Text;
var sql = string.Format("insertnto 表(a,b,c,d,e,f,g) values '{0}','{1}','{2}','{3}','{4}','{5}','{6}' ",s1,s2,s3,s4,s5,s6,s7);
sqlCommand.CommandText = sql;
sqlCommand.ExecuteNonQuery();
var s2 = txt2.Text;
var s3 = txt3.Text;
var s4 = txt4.Text;
var s5 = txt5.Text;
var s6 = txt6.Text;
var s7 = txt7.Text;
var sql = string.Format("insertnto 表(a,b,c,d,e,f,g) values '{0}','{1}','{2}','{3}','{4}','{5}','{6}' ",s1,s2,s3,s4,s5,s6,s7);
sqlCommand.CommandText = sql;
sqlCommand.ExecuteNonQuery();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询