如何在datagridview中显示sql查询出来的内容 急急急急
如何在datagridview中显示sql查询出来的内容 --------------------编程问答-------------------- string str = "select * from student";using(SqlConnection con = new SqlConnection(""))
{
com = new SqlDataAdapter(str, con);
SqlCommandBuilder cb = new SqlCommandBuilder(com);
DataSet dst= new DataSet();
com.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
} --------------------编程问答-------------------- datagridview.DataSource = 数据源(dataset,datatable ,泛型)都可以
datagridview.DataBind(); --------------------编程问答--------------------
Dim Mcom As New SqlCommand--------------------编程问答--------------------
Mcom.CommandType = CommandType.Text
Mcom.CommandText = "select * from Nh_pr"
Mcom.Connection = Mcon
Adapter.SelectCommand = Mcom
Dim Daset As New DataSet
Adapter.Fill(Daset, "Nh_pr")
Me.DataGridView1.DataSource = Daset.Tables("Nh_pr")
string str = "select * from student";
using(SqlConnection con = new SqlConnection(""))
{
com = new SqlDataAdapter(str, con);
SqlCommandBuilder cb = new SqlCommandBuilder(com);
DataSet dst= new DataSet();
com.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
补充:.NET技术 , VB.NET