如何在ecshop编写一条sql语句来插入新的商品?
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 = "";
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 = "";
追问
能否解释下这是什么意思?
能把添加一个商品所涉及到的表格都写给我吗?或者加QQ 826589334,我想请教你一些问题。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |