Trying to fill texbox.text with data from database.
code:
con.Open();
SqlCommand updatetextbox = new SqlCommand("SELECT * FROM Arbeidstaker Where Person_id = 1", con);
SqlDataReader myDataReader;
myDataReader = con.ExecuteReader();
while (myDataReader.Read())
{
TextBox1.Text = myDataReader["Fornavn"].ToString();
}
--------------------
Is there a better way?
My code offc dont work properly...
tnx
Set textbox.text with value from my database c#
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Oct 4, 2011, 5:15 AM EDT
In the above code 'pos' should be replaced by the index of the Fornavn field in the row.