Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
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 October 29th, 2003, 09:02 PM
Authorized User
 
Join Date: Jun 2003
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default binding to text box

I have the following codes. I can't figure out how to bind the right column to the right text box. PLease help me, what I have missed in the following codes.

Thanks a lot!!!

    Private Sub btnCust_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSPFirst.Click
        Dim nwindConn As SqlConnection = New SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind")

        Dim selectCMD As SqlCommand = New SqlCommand("SELECT CustomerID, CompanyName FROM Customers", nwindConn)
        selectCMD.CommandTimeout = 30

        Dim custDA As SqlDataAdapter = New SqlDataAdapter()
        custDA.SelectCommand = selectCMD

        nwindConn.Open()

        Dim custDS As DataSet = New DataSet()
        Me.txtID.Text = custDA.Fill(custDS, "Customers")
        Me.txtName.Text = custDA.Fill(custDS, "Customers")

        nwindConn.Close()


    End Sub
 
Old October 31st, 2003, 07:04 AM
Authorized User
 
Join Date: Aug 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

   Dim custDA As SqlDataAdapter = New SqlDataAdapter()
   custDA.SelectCommand = selectCMD

   nwindConn.Open()

   Dim custDS As DataSet = New DataSet()
   custDA.Fill(custDS,"Customers")

   DataTable table = custDS.Tables["Customers"]
   Me.txtID.DataBinding.Add("Text",table,"CustomerID" )
   Me.txtName.DataBinding.Add("Text",table,"CustomerN ame")

   nwindConn.Close()




L.V.L
 
Old November 1st, 2003, 12:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

I wonder why u r use Open & Close Connection to fill the DataAdapter?!? U dont need it!!! its the advantage of DataAdapter & u dont use it!

Always:),
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding Column Name to a Combo Box. jitu ADO.NET 3 June 27th, 2013 07:35 AM
Combo Box Complex Binding Example? pigparent VB Databases Basics 2 June 11th, 2008 12:08 PM
Data binding a check box badgolfer VB.NET 2002/2003 Basics 9 July 20th, 2007 02:15 PM
Binding a DataReader To A List Box testsubject ADO.NET 3 December 21st, 2005 06:41 AM
binding a text box robb Access 1 May 25th, 2004 11:46 PM





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