Doing multiple ODBC queries

I’m trying to loop through an array, doing a odbcResultset.execute with a different sql statement each time, but…

 it don' work

here’s the (pseudo) code…

Dim conHAPL As New ODBCConnection

conHAPL.ConnectTo(“hapl”)

If Not conHAPL.IsConnected Then

Print "No Connection to DB: hapl"

Exit Sub

End If

conHAPL.SilentMode = True ’ we don’t want to be bothered by popups

Dim qryAllWhatever As New ODBCQuery

Set qryAllWhatever.Connection = conHAPL

Dim resResultSet As New ODBCResultSet

…[get stuff, like an array of strings called varTableList]

Forall x In varTableList

sTableName = Cstr(x)



qryAllWhatever.SQL = "SELECT * FROM " & sTableName

Set resResultSet.Query = qryAllWhatever

If Not resResultSet.Execute Then

	Print resResultSet.GetExtendedErrorMessage,,resResultSet.GetErrorMessage

	Exit Sub

End If

… [process the result set]

resResultSet.Close(DB_CLOSE)

If conHAPL.IsConnected Then

	bFlag = conHAPL.Disconnect

End If			

End Forall ’ x in varTableList

This works fine for the first element of varMetaData, but the second time around resResultSet.Execute is false, but the error messages are…

NO ERROR 500 NO ERROR

Like it’s fine, just false. Bah humbug!

I’ve tried calling resResultSet.Close after I’ve finished with it, without that, putting the dim’s inside the loop, disconnecting the conHAPL, lots of things.

So I’m left with the question:- Can I actually do this?

Kind regards

Tim

Subject: Arrrggghh! Ignore me!

This is what happens when you have a sql statement that returns nothing…

I had spelt the table name wrong!

Tim

Subject: doing multiple ODBC queries

Hi Tim

withing the for loop you have done

If conHAPL.IsConnected Then

bFlag = conHAPL.Disconnect

End If

when second time execution will start no connection will be found.

apply

If conHAPL.IsConnected Then

bFlag = conHAPL.Disconnect

End If

after end forall statement

Manu