Solved

Table Long datatype and ADO adInteger parameter datatype

Posted on 2003-11-13
2
2,321 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
Comment Utility
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now