Results 1 to 2 of 2

Thread: [RESOLVED] Data Binding to a TextBox

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Resolved [RESOLVED] Data Binding to a TextBox

    Hi Guys,
    I am really new to Dataset, DataTables, and all the rest of it!

    This is the code i have:

    VB Code:
    1. Private dsetDB As DataSet
    2.     Private daptVisit As SqlCeDataAdapter
    3.     Private dtabVisit As DataTable
    4.     Private sqlCmd As SqlCeCommand
    5.  
    6.     Private boolLoading As Boolean = True
    7.  
    8.     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    9.         If Database.openConnection() Then
    10.             Debug.WriteLine("Connection Open")
    11.         Else
    12.             Debug.WriteLine("Connection Closed")
    13.         End If
    14.  
    15.         dsetDB = New DataSet("Visit")
    16.         daptVisit = New SqlCeDataAdapter("SELECT visitID FROM currentVisit", Database.sqlConn)
    17.  
    18.         Dim cbldVisit As New SqlCeCommandBuilder(daptVisit)
    19.  
    20.         daptVisit.Fill(dsetDB, "Visits")
    21.         dtabVisit = dsetDB.Tables("Visit")
    22.  
    23.         lblVisit.Text = "VisitID"
    24.  
    25.         textVisit.DataBindings.Add("Text", dtabVisit, "visitID")
    26.  
    27.         boolLoading = False
    28.     End Sub
    29.  
    30.     Private Sub textVisit_Validated1(ByVal sender As Object, ByVal e As System.EventArgs) Handles textVisit.Validated
    31.         Me.BindingContext(dtabVisit).EndCurrentEdit()
    32.     End Sub

    Now i don't know exactly how all of this code works, i found some code in a book and have changed it so that it is relevant to my DB. Now i keep gettin an error on the line

    VB Code:
    1. textVisit.DataBindings.Add("Text", dtabVisit, "visitID")

    and as i am completely new to this i dont know why this is happening or how to fix it, so could someone please help me!

    The error i am getting is ArgumentNullException - An error message cannot be displayed because an optional resource assembly containing it cannot be found

    If anybody could help me i would greatly appreciate it.

    Thanks in advance for any help
    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Re: Data Binding to a TextBox

    Managed to fix it....it turns out
    VB Code:
    1. dtabVisit = dsetDB.Tables("Visit")

    should have been

    VB Code:
    1. dtabVisit = dsetDB.Tables("Visits")

    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width