Solved

Table Long datatype and ADO adInteger parameter datatype

Posted on 2003-11-13
2
2,332 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Access / SQL Server - ODBC Problems 16 59
default value of combobox 25 70
Access VBA Expected end of statement 5 54
MS Access Duplicate Data Assistance 9 29
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

751 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