首页上一页 1 下一页尾页 1 条记录 1/1页
为什么一次插入两条记录
发表在ASP.NET图书答疑
2010-04-20
是否精华
是
否
版块置顶:
是
否
protected void Button1_Click(object sender, EventArgs e)
{
string xm = this.TextBox1.Text.Trim();
string bmsj = this.TextBox2.Text.Trim();
string jdxhm = this.TextBox3.Text.Trim();
string byhm = this.TextBox4.Text.Trim();
string jtdh = this.TextBox5.Text.Trim();
string jtzz = this.TextBox6.Text.Trim();
string bh = this.TextBox7.Text.Trim();
string jcxf = this.TextBox8.Text.Trim();
string lszy = this.TextBox9.Text.Trim();
string zczy = this.TextBox10.Text.Trim();
string sjap = this.TextBox11.Text.Trim();
string sfxs = RadioButtonList1.SelectedValue.Trim();
string xb = RadioButtonList2.SelectedValue.Trim();
string jsfs = RadioButtonList3.SelectedValue.Trim();
string szxx = RadioButtonList4.SelectedValue.Trim();
string sznj = RadioButtonList5.SelectedValue.Trim();
string szb = RadioButtonList6.SelectedValue.Trim();
string jb = RadioButtonList7.SelectedValue.Trim();
SqlConnection mycon3 = new SqlConnection("server=.;uid=sa;pwd=;database=my;");
mycon3.Open();
string mysql3 = "INSERT INTO new(姓名,性别,级别,接送方式,接短信号码,备用号码,家庭电话,所在学校,所在年级,所在班,接送地址,教材学费,老师注意,坐车注意,时间安排,报名日期,是否新生)";
string mysql33 = " VALUES('" + xm + "','" + xb + "','" + jb + "','" + jsfs + "','" + jdxhm + "','" + byhm + "','" + jtdh + "','" + szxx + "','" + sznj + "','" + szb + "','" + jtzz + "','" + jcxf + "','" + lszy + "','" + zczy + "','" + sjap + "','" + DateTime.Now + "','" + sfxs + "')";
string mysql4 = mysql3 + mysql33;
SqlCommand cmd8 = new SqlCommand(mysql4, mycon3);
cmd8.ExecuteNonQuery();
mycon3.Close();
}
{
string xm = this.TextBox1.Text.Trim();
string bmsj = this.TextBox2.Text.Trim();
string jdxhm = this.TextBox3.Text.Trim();
string byhm = this.TextBox4.Text.Trim();
string jtdh = this.TextBox5.Text.Trim();
string jtzz = this.TextBox6.Text.Trim();
string bh = this.TextBox7.Text.Trim();
string jcxf = this.TextBox8.Text.Trim();
string lszy = this.TextBox9.Text.Trim();
string zczy = this.TextBox10.Text.Trim();
string sjap = this.TextBox11.Text.Trim();
string sfxs = RadioButtonList1.SelectedValue.Trim();
string xb = RadioButtonList2.SelectedValue.Trim();
string jsfs = RadioButtonList3.SelectedValue.Trim();
string szxx = RadioButtonList4.SelectedValue.Trim();
string sznj = RadioButtonList5.SelectedValue.Trim();
string szb = RadioButtonList6.SelectedValue.Trim();
string jb = RadioButtonList7.SelectedValue.Trim();
SqlConnection mycon3 = new SqlConnection("server=.;uid=sa;pwd=;database=my;");
mycon3.Open();
string mysql3 = "INSERT INTO new(姓名,性别,级别,接送方式,接短信号码,备用号码,家庭电话,所在学校,所在年级,所在班,接送地址,教材学费,老师注意,坐车注意,时间安排,报名日期,是否新生)";
string mysql33 = " VALUES('" + xm + "','" + xb + "','" + jb + "','" + jsfs + "','" + jdxhm + "','" + byhm + "','" + jtdh + "','" + szxx + "','" + sznj + "','" + szb + "','" + jtzz + "','" + jcxf + "','" + lszy + "','" + zczy + "','" + sjap + "','" + DateTime.Now + "','" + sfxs + "')";
string mysql4 = mysql3 + mysql33;
SqlCommand cmd8 = new SqlCommand(mysql4, mycon3);
cmd8.ExecuteNonQuery();
mycon3.Close();
}