Get Recordset

lpaul

Active member
Joined
Dec 7, 2005
Messages
27
Programming Experience
Beginner
When I run the GetRecordset Function I am getting "Invalid SQL statement; expected 'Delete', Insert, Procedue, select, orupdate in GetRecordset"

I just trying to access data that will be used in another function in this Module. The strQuery opens the query but I can figure out what I have done wrong. I am using aDO no ADO.net to get my recordset. Help!!!
mad.gif


Public Sub OpenConDatabase(ByRef xFile As String)
Dim ADODB As Object
On Error Resume Next
gConData = Nothing
gConData = New ADODB.Connection
Dim OleDb As Object
On Error Resume Next

gConData.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " ";" "

gConData.Open()

End Sub


Public Function GetRecordset(ByVal rs As ADODB.Recordset, ByVal strQuery As String, ByVal intCmdType As Short) As Object


On Error GoTo ErrorHandler
Dim SQL As String = strQuery
Dim Condata As New ADODB.Connection
Dim da As New OleDbDataAdapter
Dim ds As New DataSet("t")
Dim rss As New ADODB.Recordset

Condata.Open(gConData.ConnectionString, "", "", -1)
rss.Open(strQuery, Condata, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic, 1)
da.Fill(ds, rs, "test")
myform3.datagridtitles.SetDataBinding(ds, "test1")
GetRecordset = rss

Exit Function

ErrorHandler:
MsgBox(Err.Description & " in GetRecordset", MsgBoxStyle.Critical)
End Function
 
Back
Top