如何在ecshop编写一条sql语句来插入新的商品?

2024-11-20 03:30:57
推荐回答(1个)
回答(1):

string data_username = textBox1.Text;
string data_userpassword = textBox2.Text;//变量赋值

SqlConnection conn = new SqlConnection();//建立连接
conn.ConnectionString = @"Server=.;Integrated Security=True;" + "DataBase=JJJJJJJJ";//连接字符串
SqlCommand cmd = new SqlCommand("select * from USER_TABLE", conn);//建立命令

cmd.CommandText = "insert into USER_TABLE(ID,PS) values('" + data_username + "','" + data_userpassword + "')";//插入记录

cmd.Connection = conn;

conn.Open();
cmd.ExecuteNonQuery();

conn.Close();
MessageBox.Show("添加成功!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.textBox1.Text = "";
this.textBox2.Text = "";