468,463 Members | 2,021 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,463 developers. It's quick & easy.

how to bind data to textbox from dataset?

Hello,

I have successfully created an oledbconnection (oleconn)
to an Access mdb file along with an oleaDBdapter (oleda)
and a dataset (ds1). If I loop through the dataset

For i = 1 to 10
For Each col in ds1.Tables(0).Columns...
Console.Write col....(0,i), ...(1,i)...(2,i)
Next
next

I get data for the whole table. I defined the table name
from Access (tbl1) as dtTbl1, and each of 3 fields (fld1,
fld2, fld3) as dcfld1, dcfld2, dcfld3 in the dataset
object. Now I have 3 textboxes on a form, txt1, txt2,
txt3. When I bind these controls to the dataset I see ds1
in the Databindings Property. When I expand ds1 I see
tbl1 (not dtTbl1) and then when I expand tbl1 I see
fld1... (and not dcfld1...). So I select fld1 and press
Enter and for txt2, txt3. (Note: I do see dtTbl1 in the
Databindings property just below ds1. I tried selecting
that and the fields dcfld1..., but that did not yield
anything either).

So on the Form Load event I have
ds1.Clear()
oleda.Fill(ds1, "tlb1")

But when the form loads I do not see any data in my
textboxes. Obviously I am missing something. I mean,
yeah, I could programmatically populate each textbox, but
I need to do it through the Databindings. I would be very
appreciative if someone could tell me what else I need to
do for data to show up in my textboxes with databinding.
Then I could take it from there to cycle through the rows
of the dataset.

Thanks in advance,
Rich
Nov 20 '05 #1
4 9621
Cor
Hi Rich,

Have a look at the "currencymanager",

If you do not succeed send a message tomorrow, than I can see how I can help
you with some samples.

Or maybe someone else is sending you that here.

Cor

I have successfully created an oledbconnection (oleconn)
to an Access mdb file along with an oleaDBdapter (oleda)
and a dataset (ds1). If I loop through the dataset

For i = 1 to 10
For Each col in ds1.Tables(0).Columns...
Console.Write col....(0,i), ...(1,i)...(2,i)
Next
next

I get data for the whole table. I defined the table name
from Access (tbl1) as dtTbl1, and each of 3 fields (fld1,
fld2, fld3) as dcfld1, dcfld2, dcfld3 in the dataset
object. Now I have 3 textboxes on a form, txt1, txt2,
txt3. When I bind these controls to the dataset I see ds1
in the Databindings Property. When I expand ds1 I see
tbl1 (not dtTbl1) and then when I expand tbl1 I see
fld1... (and not dcfld1...). So I select fld1 and press
Enter and for txt2, txt3. (Note: I do see dtTbl1 in the
Databindings property just below ds1. I tried selecting
that and the fields dcfld1..., but that did not yield
anything either).

So on the Form Load event I have
ds1.Clear()
oleda.Fill(ds1, "tlb1")

But when the form loads I do not see any data in my
textboxes. Obviously I am missing something. I mean,
yeah, I could programmatically populate each textbox, but
I need to do it through the Databindings. I would be very
appreciative if someone could tell me what else I need to
do for data to show up in my textboxes with databinding.
Then I could take it from there to cycle through the rows
of the dataset.

Thanks in advance,
Rich

Nov 20 '05 #2
So how do you bind a textbox to a dataset. I can't get any of my data to show up...
Nov 20 '05 #3
Try this after setting the bindings in the Databindings
property for each textbox (this sets the CurrencyManager):

'for 1st rec
Me.BindingContext(dataset1, "Table1").Position = 0

-----Original Message-----
So how do you bind a textbox to a dataset. I can't get any of my data to show up....

Nov 20 '05 #4
Cor
Hi Sarah and also for Rich,

\\\
dim cma As CurrencyManager
cma = CType(BindingContext(dataset1.Tables(0)), CurrencyManager)
textbox1.DataBindings.Add(New Binding("Text", dataset1.Tables(0),
"LastName"))
///
I hope this helps

Cor
So how do you bind a textbox to a dataset. I can't get any of my data to

show up...
Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Mike | last post: by
3 posts views Thread by JimmyKoolPantz | last post: by
1 post views Thread by Overseer | last post: by
3 posts views Thread by vineetbatta | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.