Subject: Data type mismatch problem
Posted By: dominic_huang Post Date: 11/14/2004 3:31:36 AM
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


Reply By: doosti Reply Date: 11/14/2004 6:30:24 AM
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.
Reply By: dominic_huang Reply Date: 11/14/2004 12:10:54 PM
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 & "#)")



Reply By: happygv Reply Date: 11/15/2004 2:12:01 AM
Comment out the Conn.EXECUTE line and try this before that line.
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

Go to topic 22105

Return to index page 716
Return to index page 715
Return to index page 714
Return to index page 713
Return to index page 712
Return to index page 711
Return to index page 710
Return to index page 709
Return to index page 708
Return to index page 707