string s = "Data Source=200.200.0.244;User ID=sa;Password= ;Initial Catalog=FSDBMR; ";//指定连接
con = new SqlConnection(s);
con.Open();
string sql = "SELECT * from TT WITH (HOLDLOCK)"; sda = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
sda.Fill(ds, "Table1");//将数据表的内容填充到sda
this.dataGridView1.DataSource = ds.Tables[0]; //设置数据源
怎么对TT进行加锁,使别人不能更改此表。
con = new SqlConnection(s);
con.Open();
string sql = "SELECT * from TT WITH (HOLDLOCK)"; sda = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
sda.Fill(ds, "Table1");//将数据表的内容填充到sda
this.dataGridView1.DataSource = ds.Tables[0]; //设置数据源
怎么对TT进行加锁,使别人不能更改此表。
http://topic.csdn.net/u/20100616/17/4586bea9-04e2-4e10-9e74-613f8d70987c.html?14831
con = new SqlConnection(s); string sql = "SELECT * from TT WITH (HOLDLOCK)"; SqlCommand lockCmd = new SqlCommand(sql, con); if (con.State == ConnectionState.Closed) con.Open(); lockCmd.ExecuteNonQuery();
sda = new SqlDataAdapter("select * from TT", con);
DataSet ds = new DataSet();
sda.Fill(ds, "Table1");//将数据表的内容填充到sda
this.dataGridView1.DataSource = ds.Tables[0]; //设置数据源 我这样改了之后还是能插入数据啊????55555555