Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 21st, 2004, 12:13 PM
Authorized User
 
Join Date: Apr 2004
Location: , , .
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.
Reply With Quote
  #2 (permalink)  
Old April 21st, 2004, 01:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
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.
Reply With Quote
  #3 (permalink)  
Old April 21st, 2004, 02:01 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
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.
Reply With Quote
  #4 (permalink)  
Old April 21st, 2004, 02:39 PM
Authorized User
 
Join Date: Apr 2004
Location: , , .
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?

Reply With Quote
  #5 (permalink)  
Old April 21st, 2004, 03:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
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?
Reply With Quote
  #6 (permalink)  
Old April 21st, 2004, 03:13 PM
Authorized User
 
Join Date: Apr 2004
Location: , , .
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.

Reply With Quote
  #7 (permalink)  
Old April 21st, 2004, 03:25 PM
Authorized User
 
Join Date: Apr 2004
Location: , , .
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.

Reply With Quote
  #8 (permalink)  
Old April 21st, 2004, 08:27 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:16 AM.


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