PDA

Click to See Complete Forum and Search --> : Binding text boxes


NOTSOSURE
Mar 8th, 2004, 04:21 AM
HEY

Im just wondering how do u bind information from a database to textboxes using code

i have the following fields in a database called ROOM stored in a MS Access File called Hotel.mdb

roomID
RoomNumber
Description

so in other words bind the following

roomID = TextBox1.text
roomNumber = TextBox2.text
Description = TextBox2.text

then i would like to navigate the fields using a button to goto a previouse entry in the database and to goto the next entry in the database

im not sure how to do it please help

thanks

davidrobin
Mar 9th, 2004, 05:01 PM
I have had problems with binding to a text box also. The only way I have done it so far is to use a datareader.

Makhlouf
Mar 15th, 2004, 07:24 AM
Hiiiiii ....

you can binding textbox by this code:

me.textbox.datasource=dataset
me.textbox.datamember="tabel name"
me.textbox.datavaluefield="col name to be sorting with"
me.textbox.datatextfield="col name which we need to displsy"
sqldataadapter.fill(dataset)
me.textbos.databind

Fishcake
Mar 15th, 2004, 10:01 AM
So what you want is to navigate through records, displaying 1 record on screen at a time?

I'd say the easiest way is to retrieve the data from the database into a array,datatable or SQLDataAdapter.

then have some code behind a button like

sub Next_click(ByVal s as object,ByVal e as eventargs)
indexcount += 1
if indexcount <= dt.rows.count
' dt is a datatable
textbox1.text = dt.Rows(indexcount).Item(0)
textbox2.text = dt.Rows(indexcount).Item(1)
textbox3.text = dt.Rows(indexcount).Item(2)
else
'end of data reached
end if
end sub

davidrobin
Mar 16th, 2004, 03:35 AM
Ahhhh!!!

Now i see