Click to See Complete Forum and Search --> : ODBC Driver Error when I try to write in a MysQL DB using ASP.3.0 Code.


alrodri
06-05-2004, 05:14 PM
Hello Folks,

I'm trying to interact ASP 3.0 & MySQL 4.0, having the following codes:

37-set tblpruebas = Server.CreateObject("ADODB.RecordSet")
38-
39-strSQL="SELECT * FROM tblpruebas ORDER BY PRID"
40-tblpruebas.Open strSQL, cnMySQL, adOpenDynamic, adLockOptimistic,adCmdText
41-
42-if tblpruebas.EOF then
43- tblpruebas.AddNew
44- tblpruebas("PRID")=1
45-else
46- tblpruebas.MoveLast
47- vPRID=tblpruebas("PRID")
48- tblpruebas.AddNew
49- tblpruebas("PRID")=vPRID+1
50-end if
51-
52-tblpruebas("PRNOM")=vNom
53-tblpruebas("PRMAIL")=vMail
54-
55-tblpruebas("PRCODE")=vCode
56-tblpruebas("PRDATE")=Date()
57-
58-tblpruebas.UpDate
59-tblpruebas.Close
60-cnMySql.Close

The table “tblpruebas” has the following fields:

PRID----Type: INT
PRNOM---Type: VARCHAR(50)
PRMAIL--Type: VARCHAR(50)
PRCODE--Type: INT
PRDATE--Type: DATE

But I receive the following error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e21'
Multiple-step OLE DB operation generated errors. Check each OLE DB status value,
if available. No work was done.
/p/index.asp, line 52

This error could be cause of:

- Incompatible field names from written codes with the real field name that the table has: I’m sure that is OK
- Incompatible field data type with the data I’m trying to write. It does not exist because I pretend to introduce “Jim” in a VARCHAR(50) MySQL data type.
- The string I’m trying to introduce is longer than the configured length of the VARCHAR field. It doesn’t happen.

If I apply a commentary to 52 and 53 lines (Those of the string), everything works perfect. The exception is that I don’t save “Nombre” nether “eMail” fields. I mean that the code goes OK with the “AddNew” method, but it just works correctly with “INT” and “DATE” fields.

I have been testing, getting the same error, with the following ways:

52-tblpruebas("PRNOM")="Juan" //Writing directly the string

="'Juan'"
="'"&vNom&"'"
=trim(request.form("vNom"))

I have been changed VARCHAR field by MEDIUMTEXT ones, but I get a new error in line 58 (UpDate method)

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Invalid string or buffer length
/p/index.asp, line 58

I have could do it correctly using the INSERT sentence with the PHPMyAdmin.

When I read the fields data it works OK

Thanking you in advance,