Solved

Table Long datatype and ADO adInteger parameter datatype

Posted on 2003-11-13
2
2,329 Views
Last Modified: 2008-03-06
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
0
Comment
Question by:stevbe
2 Comments
 
LVL 39

Accepted Solution

by:
stevbe earned 0 total points
ID: 9748004
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
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question