1
2 这是第一个窗体的代码
3
4 private void button1_Click(object sender, EventArgs e)
5 {
6 while (true)
7 {
8 SqlConnection conn = new SqlConnection("Data Source=DMWIAJHLRQMX6QS;Initial Catalog=test;Persist Security Info=True;User ID=sa;Pwd=111111");
9 conn.Open();
10 string cmdStr = "insert into test_interfacetable0760 with(xlock) (SendPhone,text,SendTime,states,UserID) values ('13888888888','测试内容','2013-8-14',1,32) ";
11 SqlCommand cmd = new SqlCommand();
12 cmd.Connection = conn;
13 cmd.CommandText = cmdStr;
14 try
15 {
16 cmd.ExecuteNonQuery();
17 }
18 catch (Exception ex)
19 {
20 MessageBox.Show(ex.Message);
21 }
22 finally
23 {
24 conn.Close();
25 }
26 }
27 }
28
29
30 这是第二个窗体的代码
31
32 private void button1_Click(object sender, EventArgs e)
33 {
34 while (true)
35 {
36 SqlConnection conn = new SqlConnection("Data Source=DMWIAJHLRQMX6QS;Initial Catalog=test;Persist Security Info=True;User ID=sa;Pwd=111111");
37 conn.Open();
38 SqlCommand cmd = new SqlCommand();
39 cmd.Connection = conn;
40 string selecStr = "select top 1 * from test_interfacetable0760 with(xlock) where states=1 ";
41 cmd.CommandText = selecStr;
42 int tempid = Convert.ToInt32(cmd.ExecuteScalar());
43 string cmdStr = "update test_interfacetable0760 with(xlock) set SendPhone='13777777777',text='更新的测试内容',SendTime='2000-8-14',states=2,UserID=22 where tempid=" + tempid + "";
44 cmd.CommandText = cmdStr;
45 try
46 {
47 cmd.ExecuteNonQuery();
48 }
49 catch (Exception ex)
50 {
51 MessageBox.Show(ex.Message);
52 }
53 finally
54 {
55 conn.Close();
56 }
57 }
58 }
我 开着两个程序同时运行的时候,操作什么的都正确(数据库可以看见这些操作的正确性),可是内存在不停的增加,cpu也占用100%了,这是为什么呢
- 5 回答
- 0 关注
- 793 浏览
添加回答
举报
0/150
提交
取消