farhadtolooie
asked on
databindings
hello experts ,
I want to query database and retrieve value of a field of table , and put it in textbox1,I wrote these :
Dim cn As OleDbConnection = New OleDbConnection("provider= microsoft. jet.oledb. 4.0; _
data source=d:\db1.mdb")
cn.Open()
Dim da As OleDbDataAdapter = New OleDbDataAdapter _("select * from table1 where fname='hossein'", cn)
Dim ds As DataSet = New DataSet
TextBox1.DataBindings.Add( "text", ds, "table1.lname")
da.Fill(ds)
but when I run this , error appear :
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
Additional information: Cannot create a child list for field table1.
please help me to correct these codes,
is there better way?
thanks
I want to query database and retrieve value of a field of table , and put it in textbox1,I wrote these :
Dim cn As OleDbConnection = New OleDbConnection("provider=
data source=d:\db1.mdb")
cn.Open()
Dim da As OleDbDataAdapter = New OleDbDataAdapter _("select * from table1 where fname='hossein'", cn)
Dim ds As DataSet = New DataSet
TextBox1.DataBindings.Add(
da.Fill(ds)
but when I run this , error appear :
An unhandled exception of type 'System.ArgumentException'
Additional information: Cannot create a child list for field table1.
please help me to correct these codes,
is there better way?
thanks
ASKER
hello roger
I wrote your code and run it , but this error occur:
An unhandled exception of type 'System.Data.OleDb.OleDbEx ception' occurred in system.data.dll
what doyou think about it?
what's the problem?
farhad
I wrote your code and run it , but this error occur:
An unhandled exception of type 'System.Data.OleDb.OleDbEx
what doyou think about it?
what's the problem?
farhad
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Rolling all that together (and assuming that your table has a field called "lname") try this.
Dim cn As OleDbConnection = New OleDbConnection("provider=
data source=d:\db1.mdb")
Dim da As OleDbDataAdapter = New OleDbDataAdapter _("select * from table1 where fname='hossein'", cn)
Dim dt As New DataTable
da.Fill(dt)
TextBox1.DataBindings.Add(
Roger