Results 1 to 9 of 9

Thread: .NET 2.0+ WinForms Data-binding

Threaded View

  1. #7
    Member
    Join Date
    Apr 2007
    Posts
    52

    Re: .NET 2.0+ WinForms Data-binding

    jmcilhinney,

    Hi! I'm trying to databind a pair of textboxes to a dataset based on a stored procedure and for some reason it's failing. Where am I going wrong?

    Edit: Form1.adid is a variable passed from another form and captured from the system environment of the user that correllates with the parameter of the stored procedure. Just FYI so you know why it's there.

    Code:
            connection.Open()
    
            'populate text boxes
    
            Dim cmSQL As SqlCommand = New SqlCommand("getAgent", connection)
            cmSQL.CommandType = CommandType.StoredProcedure
            cmSQL.Parameters.AddWithValue("@IID", Form1.adid)
            Dim daAgent As New SqlDataAdapter(cmSQL)
            daAgent.SelectCommand = cmSQL
            Dim dsAgent As New DataSet
    
            daAgent.Fill(dsAgent)
    
            Try
                Me.TextBox1.DataBindings.Add("Text", dsAgent.Tables(0).Columns(0), "Name")
                Me.TextBox2.DataBindings.Add("Text", dsAgent.Tables(0).Columns(1), "[Sprint Email]")
            Catch ex As System.Exception
                'System.Windows.Forms.MessageBox.Show(ex.Message)
                MsgBox("Unable to retrieve your Name and Email address.", MsgBoxStyle.Exclamation, "Database Error")
            End Try
    Many thanks in advance!
    Last edited by ZoeWashburn; Jan 10th, 2011 at 01:35 PM.
    "Never shall I fail my comrades, nor leave any to fall;
    For we are not separate persons, but one Guardian to All."

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