Visual Studio 2017

  • Thread starter Thread starter Thushan Withanage
  • Start date Start date
T

Thushan Withanage

Guest
I want to get a record, from a sql server database table, into text boxes. some fields are empty. when i use the sqldatareader to get the record it says cannot get null data using sqldatareader.
SqlConnection con;
SqlCommand cmd;
SqlDataReader dr;

search_btn_click()
{

con.open();
cmd = new SqlCommand("select * from Student",con);
dr = cmd.ExcecuteReader();

while(dr.Read())
{
txt1.Text = dr.GetString(0);
txt2.Text = dr.GetString(1); //This column is empty
txt3.Text = dr.GetString(2);
txt4.Text = dr.GetString(3);
}
dr.Close();
con.Close();

}

Continue reading...
 

Similar threads

T
Replies
0
Views
74
Thushan Withanage
T
T
Replies
0
Views
72
Thushan Withanage
T
T
Replies
0
Views
72
Thushan Withanage
T
M
Replies
0
Views
108
Meladl
M
Back
Top