|
-
Mar 8th, 2004, 05:21 AM
#1
Thread Starter
Addicted Member
Binding text boxes
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
-
Mar 9th, 2004, 06:01 PM
#2
Fanatic Member
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.
-
Mar 15th, 2004, 08:24 AM
#3
New Member
Binding TextBox
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
-
Mar 15th, 2004, 11:01 AM
#4
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
VB Code:
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
-
Mar 16th, 2004, 04:35 AM
#5
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|