Home > Net >  C # urgent for help! Save the children! How can click on the button to show the first line of the da
C # urgent for help! Save the children! How can click on the button to show the first line of the da

Time:11-24

Seek guidance can add my qq 568172681 detailed talk about? Will delay you for a moment of time!

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.html


You 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 queries

CodePudding user response:

Learning the data binding,

CodePudding user response:

refer to the second floor Summer_djz response:

https://www.cnblogs.com/arxive/p/5943850.html

You can refer to the


Using (SqlConnection conn=new SqlConnection (ConfigurationManager ConnectionStrings [r]. "connStr" ToString ()))
{


}


Note connStr to you in the configuration file to set your database connection string, detailed setting method to baidu

CodePudding user response:

Or you don't have to go to see you write directly to death can also is a novice
String SQL="connection string";
Using (SqlConnection conn=new SqlConnection (SQL)
{


}

CodePudding user response:

Child, don't panic, the code can help you on the second floor,

CodePudding user response:

Thank you bosses guidance!
  •  Tags:  
  • C#
  • Related