开发工具:
文件大小: 77kb
下载次数: 0
上传时间: 2011-08-20
详细说明: private void button3_Click(object sender, EventArgs e) { string number = textBox2.Text; string bookname = textBox3.Text; string press = textBox4.Text; string name = textBox6.Text; string price = textBox5.Text; DateTime dt= dateTimePicker1.Value; string bookid = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); MessageBox.Show(bookid); string sql1 = "update book set number='{0}',bookname ='{ 1}',press='{2}',price='{3}',dt='{4}'where bookid ='{5}' "; sql1 = string.Format(sql1,number, bookname,press,price,dt,bookid); string sql2 = "update categorybook set name='{0}'where categoryid in(select categoryid from book where bookid='{1}')"; sql2 = string.Format(sql2, name, bookid); SqlConnection conn = new SqlConnection(); conn.ConnectionString="server=20110810-1559\\SQLEXPRESS;database=stums;integrated security=true"; //conn.ConnectionString = "server=XP-201108091130\\SQLEXPRESS;database=stums;uid=sa;pwd=0"; conn.Open(); SqlTransaction st = conn.BeginTransaction(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; try { cmd.CommandText = sql1; cmd.ExecuteNonQuery(); cmd.CommandText = sql2; cmd.ExecuteNonQuery(); st.Commit(); Showmsg(); MessageBox.Show("修改成功"); } catch { MessageBox.Show("修改失败"); } } private void button9_Click(object sender, EventArgs e) { if (dataGridView1.RowCount > 0) { dataGridView1.SelectAll(); } } private void button10_Click(object sender, EventArgs e) { while(dataGridView1.SelectedRows.Count > 0) { DataGridViewRow dv = dataGridView1.SelectedRows[0]; dv.Selected = false; } } private void button11_Click(object sender, EventArgs e) { string sql = "select * from book "; SqlConnection conn = new SqlConnection("server=20110810-1559\\SQLEXPRESS;database=stums;integrated security=true"); //SqlConnection conn = new SqlConnection("server=XP-201108091130\\SQLEXPRESS;database=stums;uid=sa;pwd=0"); conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); SqlDataReader sdr = cmd.ExecuteReader(); while (sdr.Read()) { ListViewItem lvi = new ListViewItem(); lvi.Text = sdr["number"].ToString(); lvi.SubItems.Add(sdr["bookname"].ToString()); lvi.SubItems.Add(sdr["price"].ToString()); listView1.Items.Add(lvi); } sdr.Close(); conn.Close(); } ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.