Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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 November 14th, 2004, 04:31 AM
Registered User
 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Data type mismatch problem

Hi guys,
    I tried to insert data into my transaction table, but I kept getting an error message saying Data Type Mismatch. I read some other articles in the forum and modify my code, but it still doesn't work. Can somebody please help me? Tks.

Error message:
Error Type:
Microsoft JET Database Engine (0x80040E07)
Data type mismatch in criteria expression.
/ITEC4477/Term Project/addToCart.asp, line 103


The following is part of my code:

dim trans_date
     dim x
     trans_date = date


     set oRStran = Server.CreateObject("ADODB.Recordset")
     sqltran = "select max (trans_id) as x from trans"
     oRStran.Open sqltran, objconn
     x = oRStran("x").Value

     intcus_id = cstr(session("cus_id"))

     Sub CreateNewOrder()
     if session("trans_id") = "" then
     x = (x + 1)
     session("trans_id") = x
     end if
     session("trans_id") = inttrans_id
Line103-> conn.Execute ("INSERT INTO trans (trans_id, cus_id, trans_date) values ('" & inttrans_id & "', '" & intcus_id & "', #"& trans_date & "#)")
     End sub
 
Old November 14th, 2004, 07:30 AM
Authorized User
 
Join Date: Nov 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by dominic_huang
 Hi guys,
    I tried to insert data into my transaction table, but I kept getting an error message saying Data Type Mismatch. I read some other articles in the forum and modify my code, but it still doesn't work. Can somebody please help me? Tks.

Error message:
Error Type:
Microsoft JET Database Engine (0x80040E07)
Data type mismatch in criteria expression.
/ITEC4477/Term Project/addToCart.asp, line 103


The following is part of my code:

dim trans_date
     dim x
     trans_date = date


     set oRStran = Server.CreateObject("ADODB.Recordset")
     sqltran = "select max (trans_id) as x from trans"
     oRStran.Open sqltran, objconn
     x = oRStran("x").Value

     intcus_id = cstr(session("cus_id"))

     Sub CreateNewOrder()
     if session("trans_id") = "" then
     x = (x + 1)
     session("trans_id") = x
     end if
     session("trans_id") = inttrans_id
Line103-> conn.Execute ("INSERT INTO trans (trans_id, cus_id, trans_date) values ('" & inttrans_id & "', '" & intcus_id & "', #"& trans_date & "#)")
     End sub


It seems to me that you are getting an error bcoz of the data type mismatched in database...what you are trying to insert is may be not valid for the data type you have seleted in the designing phase of database. You must be entering large data in a noncompatible field of database. Do check the datatype of the field in which u r inserting date.

Farzan Q.
BS(TeleCommunication)
Iqra University.
 
Old November 14th, 2004, 01:10 PM
Registered User
 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by doosti

It seems to me that you are getting an error bcoz of the data type mismatched in database...what you are trying to insert is may be not valid for the data type you have seleted in the designing phase of database. You must be entering large data in a noncompatible field of database. Do check the datatype of the field in which u r inserting date.

Farzan Q.
BS(TeleCommunication)
Iqra University.

Thanks so much for helping me out. Appreciate that. I checked my database again after reading your message. Both trans_id and cus_id are numeric fields and trans_date is Date/Time field. Strangely, no matter what I do--either removing all the quotes or just removing single quote around trans_id and cus_id field, there is another message in the same line showing "Syntax error in INSERT INTO statement." I looked up for all the book I have, but I still don't see "Syntax error" here. Would you mind telling me what I did wrong here? Thanks a lot.

Error Message:
Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error in INSERT INTO statement.
/ITEC4477/Term Project/addToCart.asp, line 103

The line with error:
conn.Execute ("INSERT INTO trans (trans_id, cus_id, trans_date) values (" & inttrans_id & ", " & intcus_id & ", #"& trans_date & "#)")
 
Old November 15th, 2004, 03:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Comment out the Conn.EXECUTE line and try this before that line.
Code:
Response.write "INSERT INTO trans (trans_id, cus_id, trans_date) values (" & inttrans_id & ", " & intcus_id & ", #"& trans_date & "#)"
Response.end
Copy the insert statement displayed on the page and post here. That should reveal the hidden culprit for this error.

Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Data type mismatch sharon5469 ASP.NET 1.0 and 1.1 Basics 2 May 27th, 2007 10:01 AM
data type mismatch karma SQL Language 3 April 6th, 2006 07:58 AM
Getting Data Type mismatch for autonumber somissac General .NET 4 March 1st, 2006 12:02 AM
Data Type mismatch error clueless_may Access VBA 1 May 5th, 2004 09:16 AM
Data Type Mismatch error transcona Classic ASP Databases 4 June 25th, 2003 07:23 PM





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