Home > database >  C # connect to the database and displayed in the datagridview
C # connect to the database and displayed in the datagridview

Time:12-11

If put the whole table datagirdview inside can be displayed, but if you want to choose one line display is not to come out, please help solve,

CodePudding user response:

You can put the want to display in SQL found out or to assign a value to a new datatable, this method should return a datarow
 if (dt. Rows. Count & gt; 0) 
{
The DataTable new_dt=dt. Clone ();
int i=0;
Foreach (DataRow Dr In dt. Rows)
{
If (I & lt; 30)
{
New_dt. ImportRow (Dr);
}
The else break;
i++;
}
}

CodePudding user response:

Just want to display a line, if the line 1, change to the select statement: select top 1 * from the Orders

If there is a specific line, just add a where clause condition specified ID number,
  • Related