I am trying to call a stored procedure from access ,but it is giving me this runtime error :
I am doing this first time so i dont know about how to pass parameters (IN and OUT)..
My code is
when i print .CommandText it shows me
{ call [ItemDesc]300817(?, ?) }
My stored procedure is below :
Need help with this...
Thanks
Code:
2147217900
Syntax error or access voilation
My code is
Code:
Public Sub createDataToAnalyze()
Dim objConnection As New ADODB.Connection
Dim objCom As ADODB.Command
Dim param1 As String
'Dim param2 As String
'Dim param3 As String
Dim provStr As String
Set objCom = New ADODB.Command
objConnection.Provider = "sqloledb"
provStr = "Data Source=BEA09;" & "Initial Catalog=Pending_ReviewsSQL;User ID=" & Environ("username") & ";Trusted_Connection=Yes;"
objConnection.Open provStr
With objCom
.ActiveConnection = objConnection
param1 = "300817"
.CommandText = "[ItemDesc]" & param1
.CommandType = adCmdStoredProc
Set param3 = objCom.CreateParameter("@desc1", adVarChar, adParamOutput, 220, adParamReturnValue)
objCom.Parameters.Append param3
Set param2 = objCom.CreateParameter("@desc2", adVarChar, adParamOutput, 220, adParamReturnValue)
objCom.Parameters.Append param2
Debug.Print (.CommandText)
Debug.Print (param3)
Debug.Print (param2)
objCom.Execute
End With
End Sub
when i print .CommandText it shows me
{ call [ItemDesc]300817(?, ?) }
My stored procedure is below :
Code:
USE [Pending_ReviewsSQL]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =================
ALTER PROCEDURE [ItemDesc]
@ItemNo varchar(200) ,
@desc1 varchar(220) out,
@desc2 varchar(220)out
AS
BEGIN
SET NOCOUNT ON;
select @desc1 = ProductDatabase.dbo.tblProductInfo.ProductDesc2,@desc2 = ProductDatabase.dbo.tblProductInfo.ProductDesc2
from belqcdata01.ProductDatabase.dbo.tblproductinfo
where ProductDatabase.dbo.tblproductinfo.ProductNumber = @ItemNo
END
Need help with this...
Thanks