Wrox Programmer Forums
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 25th, 2005, 10:45 PM
Registered User
 
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jackat_78
Default Hi EveryOne

I just want to ask if i can make a binding with my textbox and my combobox using datareader, because i'm looping the fields in my table to display in combobox, i used this command in binding my txtbox, txtbox.databinding.add("text",ds,"table.field"), then if click my combobox i found out that my binding in textbox didn't work. Do i need to put datareader in my dataset? Can u help me to do this.

Life always begin with TRUE or False
 
Old February 1st, 2005, 01:59 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

You can assign the value to the textbox by fetching the values from the datareader object and assigning it.

 
Old December 20th, 2005, 12:46 PM
Authorized User
 
Join Date: Dec 2005
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How would this be done?? As i am using Visual Studio .NEt 2003 and the "Databindings" method is not an option of my text box.

Thanks
 
Old December 20th, 2005, 01:42 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

myTextBox.Text = dataReader("fieldname")

-Peter
 
Old December 21st, 2005, 06:35 AM
Authorized User
 
Join Date: Dec 2005
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Just going back to binding a datareader to either a textbox or label (in this case a label).

Can anyone see the problem with this code below. I have run the query in SQL and it brings me back a Ward Name but when I load the page I get an error stating that there is No data exists for the row/column. I also manually set the criteria for the query and still get the same error.

Code:
        Dim cmdWardName As New Odbc.OdbcCommand("SELECT WARDNAME, WARDCODE FROM ASSETDDH.WARDS5 WHERE WARDCODE =" & "'" & strWardCode & "'", cnBarwickPas)
        cnBarwickPas.Open()
        Dim drWardName As Odbc.OdbcDataReader
        drWardName = cmdWardName.ExecuteReader()
        lblWardName.Text = drWardName("WARDNAME")
        lblWardName.DataBind()
        drWardName.Close()
        cnBarwickPas.Close()
Any ideas would be gratful.
Thanks
 
Old December 21st, 2005, 07:02 AM
Authorized User
 
Join Date: Dec 2005
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just been doing some more testing with this and I am able to use the above datareader to bind it to a drop down list (returns a single value) without a problem.

 
Old December 21st, 2005, 11:23 AM
Authorized User
 
Join Date: Dec 2005
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

But still unable to bind it to a label or text box.

 
Old December 21st, 2005, 02:32 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Why are you hung up on databinding it? That may just be overcomplicating things.

-Peter
 
Old December 21st, 2005, 02:59 PM
Authorized User
 
Join Date: Dec 2005
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How??
Basically i have a number of data readers which fire off SQL commandes to pull back a single value which i want to bind to a label/textbox.

 
Old December 21st, 2005, 09:07 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

With a reader i think you would call the next record or something like that.

Something like this maybe:
If (drWardName.Read) Then
            lblWardName.DataTextField = drWardName("WARDNAME")
            lblWardName.DataBind()
End If



======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.