I have a module where i have specified the connection string as below:
Then i have a form which has two textboxes. What i am trying to do is bind the two textboxes to a dataset in the following way:
I get the error "Cannot bind to the property or column firstname on the DataSource. Parameter name: dataMember".
What is wrong and how can i achieve this..please direct me.
Code:
Public Function Connection() As String
Return "Data Source=192.168.0.1,1433;Network Library=DBMSSOCN;Initial Catalog=test;User ID=sa;Password=123456"
End Function
Code:
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Dim CONNECTION_STRING As String = Connection()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Connection As New SqlClient.SqlConnection(CONNECTION_STRING)
Dim ds As New DataSet
Dim sql As String = "SELECT * FROM tblname"
Dim da As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(sql, Connection)
Try
da.Fill(ds, "tblname")
Finally
da.Dispose()
End Try
Me.TextBox1.DataBindings.Add("Text", ds, "firstname")
Me.TextBox1.DataBindings.Add("Text", ds, "lastname")
End Sub
What is wrong and how can i achieve this..please direct me.
Comment