int i = cmd.ExecuteNonQuery();
代码privatevoidbutton2_Click_1(objectsender,EventArgse){string货号=textBox1.Text.Trim();s...
代码private void button2_Click_1(object sender, EventArgs e) { string 货号 = textBox1.Text.Trim(); string 件数 = textBox2.Text.Trim(); string 日期 = textBox3.Text.Trim(); int 发货人电话 = int.Parse(textBox4.Text.Trim()); string 收货人 = textBox5.Text.Trim(); string 运费 = textBox6.Text.Trim(); string 提货 = comboBox1.SelectedItem.ToString(); string connStr = "Data Source=.; Initial Catalog=wuliu; User Id=sa; password=456"; SqlConnection conn = new SqlConnection(connStr); string cmdText = "insert into 货运单(货号,件数,日期,发货人电话,收货人,运费,提货) values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + comboBox1.Text + "')"; SqlCommand cmd = new SqlCommand(cmdText, conn); conn.Open(); int i = cmd.ExecuteNonQuery(); conn.Close(); MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK); }
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询