Hi,
I'm having difficulty passing a varchar parameter to a stored procedure in Access. Using VB, I pass the values of a record to a stored procedure in MS SQL Server 2k, which then adds or updates the record in the database. I can get date and integer values to pass to the recordset, but not varchar data types. I'd appreciate it if someone could tell me what I'm doing wrong.
VB Code:
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
Dim cmd1 As ADODB.Command
Set cmd1 = CreateObject("ADODB.Command")
cmd1.ActiveConnection = cnn
cmd1.CommandType = 4
cmd1.CommandText = "spSampleEdit1"
Dim prm2 As ADODB.Parameter
Set prm2 = cmd1.CreateParameter(Note, adVarChar, adParamInput, 255, Me.LBSAM_NOTES)
cmd1.Parameters.Append prm2
cmd1.Execute
VB gets down to the last line to execute and returns the error "Error converting data type varchar to int"
In my proc @Note is defined as VarChar. I don't see why this is trying to convert the varchar data to integer.
Heres my stored procedure:
ALTER PROC spSampleEdit1
/* This Proc updates a record in the sample table
*/
@SamId as int,
@Date1 as datetime,
@TsId1 as int,
@OrigId1 as int,
@CId1 as int,
@LbogId1 as int,
@Note as varchar
AS
BEGIN
/* Step 1: Add the sample information from the edit table into the main table
*/
UPDATE tblSample
SET LBSAM_DATE=@Date1, LBSAM_TS_ID=@TsId1, LBSAM_ORIG_ID=@OrigId1, LBSAM_C_ID=@CId1, LBSAM_LBOG_ID=@LbogId1, LBSAM_NOTES=@Note
WHERE LBSAM_ID=@SamId
END
GO
Any Ideas? Thanks in advance.
Jimmy211
I'm having difficulty passing a varchar parameter to a stored procedure in Access. Using VB, I pass the values of a record to a stored procedure in MS SQL Server 2k, which then adds or updates the record in the database. I can get date and integer values to pass to the recordset, but not varchar data types. I'd appreciate it if someone could tell me what I'm doing wrong.
VB Code:
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
Dim cmd1 As ADODB.Command
Set cmd1 = CreateObject("ADODB.Command")
cmd1.ActiveConnection = cnn
cmd1.CommandType = 4
cmd1.CommandText = "spSampleEdit1"
Dim prm2 As ADODB.Parameter
Set prm2 = cmd1.CreateParameter(Note, adVarChar, adParamInput, 255, Me.LBSAM_NOTES)
cmd1.Parameters.Append prm2
cmd1.Execute
VB gets down to the last line to execute and returns the error "Error converting data type varchar to int"
In my proc @Note is defined as VarChar. I don't see why this is trying to convert the varchar data to integer.
Heres my stored procedure:
ALTER PROC spSampleEdit1
/* This Proc updates a record in the sample table
*/
@SamId as int,
@Date1 as datetime,
@TsId1 as int,
@OrigId1 as int,
@CId1 as int,
@LbogId1 as int,
@Note as varchar
AS
BEGIN
/* Step 1: Add the sample information from the edit table into the main table
*/
UPDATE tblSample
SET LBSAM_DATE=@Date1, LBSAM_TS_ID=@TsId1, LBSAM_ORIG_ID=@OrigId1, LBSAM_C_ID=@CId1, LBSAM_LBOG_ID=@LbogId1, LBSAM_NOTES=@Note
WHERE LBSAM_ID=@SamId
END
GO
Any Ideas? Thanks in advance.
Jimmy211