I have a table with ID
and a Name
column i want to show the one ID
and Name
in a DataGridView
For Example in Textbox
when i enter ID
and click search button the datagridview shows the specifc record. In Search Button
I have following Code but it gives error
con.Open();
Sqlcommand cmd = new Sqlcommand("Select * from Registration where ID = '"+textBox1.Text+"'")
sqldatareader reader = cmd.Executereader();
if (reader.HasRows)
{
datagridview1.DataSource = reader.GetSqlValues()
}
How can i bind the data to datagridview?