retrieving data from database into textbox and labels

zacksofia

Member
Joined
Jul 10, 2005
Messages
10
Programming Experience
Beginner
[RESOLVED]retrieving data from database into textbox and labels

Hi

i'm having problem with using the data adapter. how am i supposed to load the data from my database into the textbox and label in a from?
I wanted to retrieve specific data from my database; for example select user name from users where userid depends on the user's input.
i have already set up the data adapter and the data set. I have already bind the textbox and the labels too but it's not working. The application won't retrieve the data from my database. I'm using Access as my database.

Hoping you guys can help me with this. I'm really desperate for answers.

i'm sorry if this question have been asked before.

thanks
 
Last edited:
Hello Kulrom,

I have tried that one before. BUt it's not working too. I can't use the OleDbDataAdapter.fill (datasetname). The error keep pointing to this part.


i'm really bad at this :(
 
Zack,

I had the same problem as you. The reason it errors at .fill is because you have tried to parameterise the dataAdapter without calling the parameter.

What I did that works:

I have a combobox which only lists usernames. You could do a text box but then you are relying on getting the correct spelling.

I created another dataAdapter that just selects username. No update, delete or insert coding required - SELECT ONLY

Add this to your dataSet.

Bind the combobox to the dataset table column.
On your Form_Load, fill this dataset, i.e. daUserName.fill(dsUsers.UserName)

Now doubleclick your combobox, so the code is added to selected_indexchanged.
now call your parameter, and fill the dataAdapter that asks for the parameter:

daUsers.SelectCommand.Parameters("@UserName").value = cboUserName.text
daUsers.fill(dsUsers.Users)

Bind the other textboxes to Forename, Surname, Department, ExtNo, Email etc etc.

Run the program. Everytime you select a user from the combobox, the textboxes retrieve the rest of the row specific to that user.

Hope that gets you on your way....

Cheers
Luke
 
Hi there Luke!

Thank you so much for the explaination and the coding. Now I know how these things work. I tried to add the coding and finally, it work! ;)

thanks again Luke :D
 
Back
Top