Solved

DataBinding Issue

Posted on 2015-02-18
3
78 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

626 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