SqlConnection conn = new SqlConnection();
conn.ConnectionString = "server=(local);uid=sa;pwd=sa;database=DatabaseName";
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from DatabaseName";
cmd.Connection = conn;
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
conn.Open();
DataSet ds = new DataSet();
sda.Fill(ds,DatabaseName);
conn.Close();
this.myDataGrid.DataSource = ds;
this.DataBind();
datagridview数据绑定
最新推荐文章于 2023-07-08 15:12:34 发布