Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application uses a value of the wrong type

Status
Not open for further replies.

ctdapper

Programmer
Feb 13, 2001
22
0
0
US
Using a stored procedure in an SQL Database with VB calling it:
CREATE procedure dbo.up_select_company
@code_id varchar(4)
as
select *
from company
where code = @code_id

VB part:
cmdcompany.Parameters.Append cmdcompany.CreateParameter("@code_id", adVarChar, adParamInput, 4, varcode)

Problem I keep getting a run time error ( application uses a value of the wrong type for the current operation) run-time error 3421, when varcode has both letters and numbers example "E234" What do the data types need to be?

varcode is decleared as string because it can either be all numbers all letters or a mixure of both.
 
This is what I came up with.

cmd.CommandType = adCmdStoredProc
Set params = cmd.Parameters

params.Append cmd.CreateParameter("@RETURN_VALUE", 3, adParamReturnValue, 0)
params.Append cmd.CreateParameter("@code_id", 200, adParamInput, 4)

Hope it helps.
RKA:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top