assigning a variable a value from a sql query
I am trying to query a MSSQL table and pull all the fields from the database and then assign them to the text fields on the form.
What I am struggling with is how I would assign the text box the value of the database table field.
Are you retrieving one record or multiple records? If it's multiple records, do you want to display all of them at once or just one at a time?
I am retrieving one record. The record has about 50 fields and each field is assigned to a seperate variable
Then use a SqlCommand, call ExecuteReader to create a SqlDataReader and read each field individually and assign it to the appropriate property of the appropriate control. For an example of using a data reader, amongst others, check out this thread:
Retrieving and Saving Data in Databases