 |
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

April 21st, 2004, 12:13 PM
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Filling in a list box with data from Access
I've got a text box search that is responding to a _TextChanged event.
I've connected to the database and written a SQL statement.
Then I have:
Dim Matches as New OleDbDataAdapter(SQLStmt, OleDbConnection1)
Dim Matches As New OleDBDataAdapter(SQLStmt, OleDbConnection1)
MatchesDataSet = New DataSet
Matches.Fill (MatchesDataSet, "MatchingRecord")
lbMatches.DataSource = MatchesDataSet.Tables("MatchingRecord")
When I search in txtSearch, lbMatches displays one name for a brief moment, then displays "System.Data.DataRowView" for each instance of name that should appear in the box.
I'm using an Access Database and MatchingRecord is a class.
|

April 21st, 2004, 01:59 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
I see no DataTextField or DataValueField parameters. Are these set? I think that may be your problem. I remember having that error before, and I think it is in relationto that.
|

April 21st, 2004, 02:01 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Also, I should say it this way, there is no databinding set up is what it seems like the problem is, so you can set it up through the databindings property also.
|

April 21st, 2004, 02:39 PM
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
This might be helpful to you, but I'm not sure what it means.
I programed an Try Catch for an error message. The message tells me: "Got this exception: 'System.InvalidOperationException: ExecuteNonQuery: Connection property has not been intialized at ......
What does this mean?
|

April 21st, 2004, 03:02 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
The ExecuteNonQuery method is a Command object method that executes the SQL with no results returned. However, Connection property has not been initialized would suggest no connection string was passed into the OLEDBConnection object. How do you set up your connection?
|

April 21st, 2004, 03:13 PM
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
To set up my connection, I used the DataAdapter wizard. My code states OleDbConnection1.open.
For a brief second, I can see one of the names in the database, then it goes away and the System.Data.DataRowView displays in the list box. I think I am connecting to the database because I put in:
If OleDbConnection1.state <> ConnectionState.open Then
MsgBox("...")
End
End If
I'm not getting my message box.
I tried setting the DataBinding Property in the Properties box to the DataSet, but I got the same result.
I'm still reading up on data binding, so I'm not sure how to hard code it yet.
|

April 21st, 2004, 03:25 PM
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I've got the .displaymember and .valuemember set in the form_load event. Still the same thing.
|

April 21st, 2004, 08:27 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
I've had this problem in the past, but now can't remember what was the problem. If I remember, I'll let you know. The only thing that is strange to me is that it is a System.Data.DataRowView, but the data source is a DataTable. Maybe that's correct, I don't know.
Sorry I couldn't be more help.
|
|
 |