CodePudding user response:
The first row of data query, they lifted up their voice, and bound to the datagridview can ah,
Select * from top 1 Table where...
CodePudding user response:
https://www.cnblogs.com/arxive/p/5943850.htmlYou can refer to the
Using (SqlConnection conn=new SqlConnection (ConfigurationManager ConnectionStrings [r]. "connStr" ToString ()))
{
SqlDataAdapter sda=new SqlDataAdapter (" select * from top 1 tablename;" , conn);
The DataSet Ds=new DataSet ();
Sda. The Fill (Ds, "tablename");
//use the DataSet binding, must also indicate the DateMember
Enclosing dataGridView1. The DataSource=Ds;
This. DataGridView1. DataMember="tablename";
//can also directly use the DataTable to bind
Enclosing dataGridView1. The DataSource=Ds. The Tables (" tablename ");
}
CodePudding user response:
Learn from each other, with SQL queriesCodePudding user response:
Learning the data binding,CodePudding user response: