Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DataBinding Issue

Posted on 2015-02-18
3
Medium Priority
?
80 Views
Last Modified: 2015-02-19
I am having a problem Binding text boxes

In the example below I would like to bind text boxes (and perhaps other controls) with the the column row I get from the query.

Currectly I am getting error:

{"Cannot bind to the property or column strCustomerType on the DataSource. Parameter name: dataMember"}

Imports System.Data
Imports System.Data.SqlClient

Public Class frmOEOrder
    Dim SQL As New SQLControl
    Public SQLCmd As SqlCommand

    Public Sub New(ByVal ID As String)
        ' This call is required by the designer.
        InitializeComponent()
        Dim PopulateCustomerQuery As String = "SELECT * FROM tblARCustomer WHERE strCustomerID ='" & ID & "'"
        If SQL.HasConnection = True Then
            SQL.RunQuery(PopulateCustomerQuery)

            'check dataset for tables before attempting to FILL DataGridView
            If SQL.SQLDataSet.Tables.Count > 0 Then
                'Populate DataGridView with DataSet
                dgvData.DataSource = SQL.SQLDataSet.Tables(0)
                BS.DataSource = SQL.SQLDataSet

                cboCustomerID.Text = SQL.SQLDataSet.Tables(0).Rows(0).Item(0).ToString
            End If
        End If
        PopulateData(SQL.SQLDataSet)
    End Sub

    Private Sub cmdQuery_Click(sender As Object, e As EventArgs) Handles cmdQuery.Click
        If txtQuery.Text <> "" Then
            If SQL.HasConnection = True Then
                SQL.RunQuery(txtQuery.Text)

                'check dataset for tables before attempting to FILL DataGridView
                If SQL.SQLDataSet.Tables.Count > 0 Then
                    'Populate DataGridView with DataSet
                    dgvData.DataSource = SQL.SQLDataSet.Tables(0)
                End If
            End If
        End If
    End Sub

    Private Sub PopulateData(ds As DataSet)
        'Procedure to bind data to controls
        BS.DataSource = ds
        strCustomerType.DataBindings.Add("Text", BS, "strCustomerType", True)
    End Sub

Open in new window

0
Comment
Question by:smartoffices
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 40618420
Since you're binding to a DataSet you will probably need to specify the table name in the binding expression.
Something like:
strCustomerType.DataBindings.Add("Text", BS, "[YourTable].strCustomerType", True)

Open in new window

0
 

Author Comment

by:smartoffices
ID: 40618683
This fixed my problem.

strCustomerType.DataBindings.Add("Text", SQL.SQLDataSet.Tables(0), "strCustomerType")
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question