写了一个登陆窗体,求如何将会员信息插入另一张登记表。
我写了一个登陆WINFORM。数据库里已经写好两张表,一张是会员信息。一张是登陆信息表。现在想的是会员登陆后,自动将会员信息插入到另一张表(记录登陆信息)。小白实在不会了,求大神教一下。
程序代码: private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
string connsql = "Data Source=.;Initial Catalog=work;Integrated Security=True";
SqlConnection conn = new SqlConnection(connsql);
conn.Open();
string mysql = "select * from t1 where id='" + textBox1.Text + "' and pass='" + textBox2.Text + "'";
SqlCommand cmd = new SqlCommand(mysql, conn);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
;
string cmdtext="insert into t2 (id,name,xx) select id,name,xx from t1";
Form2 f2 = new Form2();
f2.Show();
}
conn.Close();
}
else
{
return;
}









