|
Hi,
I run a Sybase stored procedure (with parameters) from Excel using ADODB Connetction but it returns an empty recordset.
However, if I run a stored procedure (with no parameters), it works fine.
Can anyone help me?
Thanks.
Below is my code:
Dim v_This_Row As Variant, v_Last_Row As Variant, _
v_This_Col As Variant, v_Last_Col As Variant
Dim CN As New ADODB.Connection
Dim RecSet As New Recordset
Dim Query As String
Dim strConn As String
strConn = "DSN=dbname;UID=username;PWD=pwd"
CN.ConnectionString = strConn
CN.Open
Dim sFac As String, sProduct As String
Dim iSwitch As Integer
sFac = "Fac"
sProduct = "Prod"
iSwitch = 2
Query = "execute WARS_UDB..p_aps_prodrteoper3_seq "
Query = Query & "'" & sFac & "', " & "'" & sProduct & "', " & iSwitch
Set RecSet = CN.Execute(Query)
Dim v_Col_Count
v_Col_Count = RecSet.Fields.Count
For v_This_Col = 0 To (v_Col_Count - 1)
Cells(1, v_This_Col + 1) = RecSet.Fields(v_This_Col).Name
Next v_This_Col
v_This_Row = 2
Do While Not RecSet.EOF
For v_This_Col = 0 To (v_Col_Count - 1)
Cells(v_This_Row, v_This_Col + 1) = RecSet(v_This_Col)
Next v_This_Col
RecSet.MoveNext
v_This_Row = v_This_Row + 1
Loop
'get the last row
v_Last_Row = v_This_Row - 1
RecSet.Close
CN.Close
|
|
|
|
|
|
|
// |