ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SQL Stored proc - passing parameters (https://www.excelbanter.com/excel-programming/359429-sql-stored-proc-passing-parameters.html)

Harish Mohanbabu[_3_]

SQL Stored proc - passing parameters
 
Hi,

I am trying to pass 3 parameters (2 date type and 1 string type) to a sql
stored proc from Excel. But I am getting this error message -

---------------------------
Parameter object is improperly defined. Inconsistent or incomplete
information was provided. The hex errorcode is : E7C
---------------------------

Here is my code snippet -
---------------------------------------------------------------------------
......................
......................
Dim param(3) As ADODB.Parameter
......................

Set Comm = New ADODB.Command

With Comm
..ActiveConnection = Conn
..CommandText = "<STORED_PROC"
..CommandType = adCmdStoredProc

Set param(1) = .CreateParameter("From_Date", adDate, adParamInput)
param(1).Value = frmDate

Set param(2) = .CreateParameter("To_Date", adDate, adParamInput)
param(2).Value = toDate

Set param(3) = .CreateParameter("Item_Group", adWChar, adParamInput)
param(3).Value = retValue

For i = 1 To UBound(param)
.Parameters.Append param(i)
Next i
End With
---------------------------------------------------------------------------

I am getting the above error message while trying to append the parameters -
particulary the third parameter.

The SQL stored proc works fine when called from SQL query analyzer.

What could be wrong here? Can someone help me please.

Many thanks in advance,

Harish Mohanbabu
--
Microsoft Dynamics Ax - MVP
http://www.harishm.com/

Harish Mohanbabu[_3_]

SQL Stored proc - passing parameters
 
I figured out the problem. I forgot to pass the field size ....

Harish Mohanbabu
--
Microsoft Dynamics Ax - MVP
http://www.harishm.com/


"Harish Mohanbabu" wrote:

Hi,

I am trying to pass 3 parameters (2 date type and 1 string type) to a sql
stored proc from Excel. But I am getting this error message -

---------------------------
Parameter object is improperly defined. Inconsistent or incomplete
information was provided. The hex errorcode is : E7C
---------------------------

Here is my code snippet -
---------------------------------------------------------------------------
.....................
.....................
Dim param(3) As ADODB.Parameter
.....................

Set Comm = New ADODB.Command

With Comm
.ActiveConnection = Conn
.CommandText = "<STORED_PROC"
.CommandType = adCmdStoredProc

Set param(1) = .CreateParameter("From_Date", adDate, adParamInput)
param(1).Value = frmDate

Set param(2) = .CreateParameter("To_Date", adDate, adParamInput)
param(2).Value = toDate

Set param(3) = .CreateParameter("Item_Group", adWChar, adParamInput)
param(3).Value = retValue

For i = 1 To UBound(param)
.Parameters.Append param(i)
Next i
End With
---------------------------------------------------------------------------

I am getting the above error message while trying to append the parameters -
particulary the third parameter.

The SQL stored proc works fine when called from SQL query analyzer.

What could be wrong here? Can someone help me please.

Many thanks in advance,

Harish Mohanbabu
--
Microsoft Dynamics Ax - MVP
http://www.harishm.com/



All times are GMT +1. The time now is 06:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com