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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pervasive SQL 2000 stored procedure and VB6 1

Status
Not open for further replies.

mmayo

Programmer
May 29, 2001
38
US
I have created 2 stored procedures using pervasive's Control Center. When I attempt to open a recordset using ADO, with a valid connection object, I get: 3704 - The operation requested by the application is not allowed if the object is closed.

Since there are several legacy Access databases that query the same tables for similar data, I would like to run these as stored procedures. Where am I going wrong?

Here is the code:
Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim comIndust As New ADODB.Command
Dim rs As New ADODB.Recordset
Dim rsIndust As New ADODB.Recordset
Dim strIndust As String
Dim i As Integer

On Error GoTo testErrHand

'Create connection object
With cn
.CursorLocation = adUseServer
.Open "Provider=MSDASQL.1;Persist Security Info=True;Data Source=Indust"
End With

'Verify connection works
strIndust = "Select * from OcOrder"
rsIndust.Open strIndust, cn, adOpenForwardOnly
Do While Not rsIndust.EOF
Debug.Print rsIndust(0), rsIndust(1)
rsIndust.MoveNext
Loop

'Create command object
With comIndust
.ActiveConnection = cn
.CommandType = adCmdStoredProc
.CommandText = "TestOcOrder"
End With

'Run stored procedure
Set rs = comIndust.Execute

'Open recordset
rs.MoveFirst
For i = 1 To 10
Debug.Print rs(0), rs(1)
rs.MoveNext
Next i

Set Adodc1.Recordset = rs
Set DataGrid1.DataSource = Adodc1

TestExit:
On Error Resume Next
rs.Close
Set rs = Nothing
Exit Sub

testErrHand:
MsgBox Err.Number & "-" & Err.Description
Resume TestExit
 
Instead of the following:
With comIndust
.ActiveConnection = cn
.CommandType = adCmdStoredProc
.CommandText = "TestOcOrder"
End With

Try this:
With comIndust
.ActiveConnection = cn
.CommandText = "call TestOcOrder()"
End With

 
Thanks! I came up with a longer alternate route that worked. This is exactly what I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top