If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Database Problem?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-03-04, 10:02
vpdb vpdb is offline
Registered User
 
Join Date: Jun 2004
Posts: 9
Exclamation Database Problem?

hi all...im using a n access db and vb6...
i have a program that i select a table, that is stored in a db, and do some adding to it...i keep getting a "Type Mismatch" error...

does anyone know where my problem is???
here is my code...

Set db = OpenDatabase("C:\test\orders.mdb")
Set rs2 = db.OpenRecordset(cmbTables.Text, dbOpenDynaset)
TempName = txtName.Text
TempDate = txtDate.Text
TempNumber = txtNumber.Text
TempOrder = txtOrder.Text

rs2.AddNew
rs2!Name= TempName
rs2!Date = TempDate
rs2!Number = TempNumber
rs2!Order = TempOrder

rs2.Update
MsgBox "Item Added Successfully!!" _
, vbInformation, "Added"
rs2.Close
Set rs2 = Nothing
db.Close
Set db = Nothing
Unload Form4
Load Form4
Form4.Show
End Sub

real simple code...thanks for your time....
Reply With Quote
  #2 (permalink)  
Old 09-03-04, 13:59
jwman jwman is offline
Registered User
 
Join Date: Aug 2004
Posts: 82
Was the database created in MS access 2000 or higher
Reply With Quote
  #3 (permalink)  
Old 09-04-04, 12:37
Daniel_Johns Daniel_Johns is offline
Registered User
 
Join Date: Jul 2004
Posts: 69
hi there! I supposed that the data type designated in your table for the value of txtNumber (TempNumber) is a "Number" data type...if so, you can have this code

instead of: TempNumber = txtNumber.Text

change to: TempNumber = Val(txtNumber.Text)

and check all possible "mismatch" data types...
Reply With Quote
  #4 (permalink)  
Old 09-04-04, 15:55
Ryker Ryker is offline
Registered User
 
Join Date: Nov 2003
Location: Sussex, England
Posts: 404
Casting

It might be worthwile to cast all your variables into the correct type, e.g.

TempDate = CDATE(txtDate.Text)

It might be useful to find line is chucking up the error.

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 On
Pingbacks are On
Refbacks are On