Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
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
 
Old April 21st, 2004, 12:13 PM
Authorized User
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
 
Old April 21st, 2004, 01:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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.
 
Old April 21st, 2004, 02:01 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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.
 
Old April 21st, 2004, 02:39 PM
Authorized User
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?

 
Old April 21st, 2004, 03:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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?
 
Old April 21st, 2004, 03:13 PM
Authorized User
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

 
Old April 21st, 2004, 03:25 PM
Authorized User
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've got the .displaymember and .valuemember set in the form_load event. Still the same thing.

 
Old April 21st, 2004, 08:27 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
Filling a list box with WHERE clause Scootterp Access VBA 1 March 31st, 2006 12:32 PM
filling a combo box from a data object allee_man Beginning VB 6 1 March 1st, 2005 08:08 AM
Microsoft Access List Box Teqlump SQL Language 1 October 21st, 2004 06:22 PM
Copy list box data vladimir Access 5 July 23rd, 2003 06:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.