string strConn = string.Empty;
string sql = string.Empty;
strConn = System.Configuration.ConfigurationSettings.AppSettings["test"].ToString();
sql = "select customerId,companyName,contactMan from customer with(nolock)";
SqlConnection cnn = new SqlConnection(strConn);
if (cnn.State == ConnectionState.Closed)
{
cnn.Open();
}
//MessageBox.Show(cnn.State.ToString());
SqlDataAdapter da = new SqlDataAdapter(sql,cnn);
DataSet ds = new DataSet();
da.Fill(ds);
ds.Tables[0].DefaultView.Sort = "customerId asc,contactMan desc";
dataGridView2.DataSource = ds.Tables[0].DefaultView;
cnn.Close();
WinForm的中DataGridView的应用
最新推荐文章于 2025-08-15 13:27:42 发布