Question : Table Long datatype and ADO adInteger parameter datatype

I must be dense today :-)

I have an Access database that I am using in SQL Server Compatible Syntax (ANSI 92) mode, not that I think this matters but I am trying to be thorough.

I have a parameterized query:
PARAMETERS ErrLogApp Text ( 255 ), ErrLogNo Long, ErrLogDesc Text ( 255 ), ErrLogMod Text ( 255 ), ErrLogProc Text ( 255 ), ErrLogUser Text ( 255 );
INSERT INTO ztblErrLog ( ErrLogApp, ErrLogNo, ErrLogDesc, ErrLogMod, ErrLogProc, ErrLogUser )
SELECT [ErrLogApp] AS F1, [ErrLogNo] AS F2, [ErrLogDesc] AS F3, [ErrLogMod] AS F4, [ErrLogProc] AS F5, [ErrLogUser] AS F6;


I have a public procedure signature:
Public Sub LogError(ByRef ErrLogMod As String, _
                    ByRef ErrLogProc As String, _
                    ByRef ErrLogNo As Long, _
                    ByRef ErrLogDesc As String, _
                    ByRef ErrLogDisp As Boolean)

inside this procedure I create / append a paramter object to my command object ...
    Set prm = cmd.CreateParameter(Name:="ErrLogNo", _
                                  Type:=adInteger, _
                                  Direction:=adParamInput, _
                                  Value:=ErrLogNo)
    cmd.Parameters.Append prm

when I execute:
    cmd.Execute , , adExecuteNoRecords

I get a "-2147217913: Datatype mismatch in criteria expression" error

I left out the rest of the code because if I skip executing the above posted parameter everything works just fine.

TIA,
Steve

Answer : Table Long datatype and ADO adInteger parameter datatype

It was not the code it was the query.

The query parameters MUST be in the same ordinal position as they are used in the query.

PARAMETERS ErrLogApp Text ( 255 ), ErrLogMod Text ( 255 ), ErrLogProc Text ( 255 ), ErrLogNo Long, ErrLogDesc Text ( 255 ), ErrLogUser Text ( 255 );
INSERT INTO ztblErrLog ( ErrLogApp, ErrLogMod, ErrLogProc, ErrLogNo, ErrLogDesc, ErrLogUser )
SELECT [ErrLogApp] AS F1, [ErrLogMod] AS F2, [ErrLogProc] AS F3, [ErrLogNo] AS F4, [ErrLogDesc] AS F5, [ErrLogUser] AS F6;

Steve
Random Solutions  
 
programming4us programming4us