代码如下
private void button1_Click(object sender, EventArgs e)
{ SqlConnection sqc = new SqlConnection();
sqc.ConnectionString = "Data Source=localhost;Initial Catalog=ll;Integrated Security=SSPI";
sqc.Open();
SqlCommand comm = new SqlCommand("insert into cunkuanren(name,sfz,tel,adress,bz) values(" + textBox2.Text + "," + textBox3.Text + "," + textBox4.Text + "" + textBox5.Text + "," + textBox6.Text + ")", sqc);
comm.ExecuteNonQuery();
sqc.Close(); } private void button3_Click_1(object sender, EventArgs e)
{
SqlConnection sqc = new SqlConnection();
sqc.ConnectionString = "Data Source=localhost;Initial Catalog=ll;Integrated Security=SSPI";
sqc.Open();
SqlCommand comm = new SqlCommand("update cunkuanren set name='" + textBox2.Text.Trim() + "',sfz='" + textBox3.Text.Trim() + "', tel='" + textBox4.Text.Trim() + "',adress='" + textBox5.Text.Trim() + "',bz ='" + textBox6.Text.Trim() + "'", sqc);
comm.ExecuteNonQuery();
sqc.Close();
} private void button2_Click_1(object sender, EventArgs e)
{
SqlConnection sqc = new SqlConnection();
sqc.ConnectionString = "Data Source=localhost;Initial Catalog=ll;Integrated Security=SSPI";
sqc.Open();
SqlCommand comm = new SqlCommand("delete from cunkuanren where id='" + textBox1.Text.Trim() + "'", sqc);
comm.ExecuteNonQuery();
sqc.Close();
}执行后提示 comm.ExecuteNonQuery();这句不对 哪里的问题啊 请高手帮忙
private void button1_Click(object sender, EventArgs e)
{ SqlConnection sqc = new SqlConnection();
sqc.ConnectionString = "Data Source=localhost;Initial Catalog=ll;Integrated Security=SSPI";
sqc.Open();
SqlCommand comm = new SqlCommand("insert into cunkuanren(name,sfz,tel,adress,bz) values(" + textBox2.Text + "," + textBox3.Text + "," + textBox4.Text + "" + textBox5.Text + "," + textBox6.Text + ")", sqc);
comm.ExecuteNonQuery();
sqc.Close(); } private void button3_Click_1(object sender, EventArgs e)
{
SqlConnection sqc = new SqlConnection();
sqc.ConnectionString = "Data Source=localhost;Initial Catalog=ll;Integrated Security=SSPI";
sqc.Open();
SqlCommand comm = new SqlCommand("update cunkuanren set name='" + textBox2.Text.Trim() + "',sfz='" + textBox3.Text.Trim() + "', tel='" + textBox4.Text.Trim() + "',adress='" + textBox5.Text.Trim() + "',bz ='" + textBox6.Text.Trim() + "'", sqc);
comm.ExecuteNonQuery();
sqc.Close();
} private void button2_Click_1(object sender, EventArgs e)
{
SqlConnection sqc = new SqlConnection();
sqc.ConnectionString = "Data Source=localhost;Initial Catalog=ll;Integrated Security=SSPI";
sqc.Open();
SqlCommand comm = new SqlCommand("delete from cunkuanren where id='" + textBox1.Text.Trim() + "'", sqc);
comm.ExecuteNonQuery();
sqc.Close();
}执行后提示 comm.ExecuteNonQuery();这句不对 哪里的问题啊 请高手帮忙
解决方案 »
- byte数组和字符串的转换问题,急!!!
- 如何捕获GridView 单元格中的 keydown 值?
- 怎么在datagridview的右键菜单的方法里获取datagridview所选中的行
- 如何在repeater里面添加if判断
- 请教一个关于互斥的问题,详细的描述在帖子里面,请进来看看,谢谢
- 怎样用C#写个读取未知Access数据库里面的表名
- PDA连接SQLSERVER问题(Pocket PC)
- 很想问一句,现在国内java真的比c#热吗?以后呢?
- dts-“弱智”问题!发贴两天了竟无人答
- 紧急提问,关于数据库操作的问题???????
- 如何用属性名获取匿名对象的值?
- C#中如何实现图片的自动校正
DataGridViewRow ck;
ck = this.dataGridView1.SelectedRows[0];
textBox1.Text = ck.Cells[0].Value.ToString();
textBox1.Enabled = false;
textBox2.Text = ck.Cells[1].Value.ToString();
textBox3.Text = ck.Cells[2].Value.ToString();
textBox4.Text = ck.Cells[3].Value.ToString();
textBox5.Text = ck.Cells[4].Value.ToString();
textBox6.Text = ck.Cells[5].Value.ToString();