Here is the code : You can also take the label before textbox to recognize which value you get from DB
private void button1_Click(object sender, EventArgs e)
{
string conn = "<connection String>";
OleDbConnection con = new OleDbConnection(conn);
string q = "Select name, id, id+total as tot from table1 where name='dvorkin'";
OleDbCommand cmd = new OleDbCommand(q, con);
con.Open();
OleDbDataReader dr1 = cmd.ExecuteReader();
while (dr1.Read())
{
if (dr1[0] != DBNull.Value)
{
label1.Text = "Name";
textBox1.Text = dr1[0].ToString();
}
else if (dr1[1] != DBNull.Value)
{
label1.Text = "Id";
textBox1.Text = dr1[1].ToString();
}
else if (dr1[2] != DBNull.Value)
{
label1.Text = "Total";
textBox1.Text = dr1[2].ToString();
}
else
{
MessageBox.Show("Null value found");
}
}
}
Hope this will help you