Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 10th, 2006, 07:56 AM
Authorized User
 
Join Date: Oct 2003
Location: Bronx, NY, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default type mismatch

I am experiencing a coding problem.
Essentially at this point all i'm trying to do is populate a combo box with data coming from a client table. The code appears sound however I receive a "TYPE MISMATCH" error during compilation.
The debugger points to the 'additem' property.Please review my code and tell me if you can spot the problem. Thanks in advance.
Private Sub Form_Load()

'Declare Variables
Dim cnn As ADODB.Connection
Dim AccessConnect As String
Dim ASql As String
Dim rsClient As New Recordset


Set cnn = New ADODB.Connection
AccessConnect = "DSN=Sigmund;" & _
                     "Database=sigmundt.mdb;" & _
                     "DefaultDir=D:\documents and settings\administrator.gizmo\my documents" & _
                     "visual studio projects\gizmo\client.mdb;" & _
                     "Uid=Admin;Pwd=;"

cnn.ConnectionString = AccessConnect
cnn.Open
'Build the SQL statement
ASql = "SELECT firstname FROM client" 'MUST USE DOUBLE QUOTES


'Open a recordset
rsClient.Open ASql, cnn, adOpenStatic, adLockReadOnly
Set Combo1.DataSource = rsClient
Do While Not rsClient.EOF

    Combo1.AddItem rsClient
    rsClient.MoveNext
Loop
Combo1.DataField = "FirstName"


  #2 (permalink)  
Old April 11th, 2006, 08:35 AM
Registered User
 
Join Date: Apr 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I may be wrong, but I don't think you need to set the datasource property of the Combo1 combo box. I'd recommend either binding the combo box to a datasource through the Visual Basic.net IDE (which allows you to set your select statement, display text, and item value), or, do NOT bind the combo box to a data source, and do not bind the data field. You'll have to add some extra code to grab the selectedItem from the combo box and use that in your database.

 


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
Type Mismatch Anup Gavate VB How-To 4 March 28th, 2005 01:48 PM
Type mismatch NoBullMan Classic ASP Basics 2 November 16th, 2004 03:16 AM
Type mismatch per.holleufer Classic ASP Basics 5 July 31st, 2004 07:33 AM
Type mismatch sporkman43 Classic ASP Basics 4 August 14th, 2003 03:27 AM



All times are GMT -4. The time now is 09:08 PM.


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