none
Message: - An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll RRS feed

  • Question

  • I'm getting the Message :- " Cannot bind to the property or column BusinessNumber on the DataSource.

    BusinessNumber is a Column in ans MS Access Database that the DataSource refers to.

    Has anyone an idea of why this is happening now and not in the past?

    Regards, Graham.


    Regards, Graham VB Developer

    Tuesday, March 27, 2018 4:54 AM

All replies

  • Hello Graham,

    Are you reading records via a DataAdapter or a TableAdapter or another method e.g. managed data provider?

    How are you doing the data binding, off a DataTable or a BindingSource or another way and is the data binding on a DataGridView, a TextBox etc?

    Is Business number a string or a number?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, March 27, 2018 2:31 PM
    Moderator
  • Not sure how you have implemented the data binding but if you used a TableAdapter to build your data source it could be that the column is missing from the query. In this instance you would need to re-configured the TableAdapter query using the Configuration Wizard.

    Paul ~~~~ Microsoft MVP (Visual Basic)

    Tuesday, March 27, 2018 3:12 PM
  • Hi Grahaml,

    According to your error message, and you said that BusinessNumber is a column in MS Access database, I suggest you check if this column exists in the table you queried  from the access database. I do one example that add binding to textBox, you can take a look:

     Dim ds As New DataSet
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Dim str As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\DataBase\Database1.accdb;Persist Security Info=False;"
            Dim sql As String = "Select Id, UserName, Password from Test8"
            Using conn As New OleDbConnection(str)
                conn.Open()
                Using cmd As New OleDbCommand(sql, conn)
                    Dim adapter As New OleDbDataAdapter(cmd)
                    adapter.Fill(ds)
                End Using
            End Using
            Dim bind As New BindingSource()
            bind.DataSource = ds.Tables(0)
            DataGridView1.DataSource = bind
            TextBox5.DataBindings.Add("Text", bind, "UserName")
        End Sub

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Stanly Fan Wednesday, April 4, 2018 9:20 AM
    Wednesday, March 28, 2018 2:23 AM
    Moderator