How do I retrieve data using a ODBC connection ?

I believe that my connection it s ok.
I try retrieve information from database but there is a error (ODBC called error).


parameter :
DSN=VTM,UID=VTM;PW:VTM



Dim wrkODBC As Workspace
Dim conBO As DAO.Connection
Dim dbNumeros As DataBase
Set wrkODBC = CreateWorkspace  ("VTM_Con", "VTM_Con", "", dbUseODBC)
'It s Ok
Set conBO = wrkODBC.OpenConnection  
("VTM",
dbDriverPrompt, , "ODBC;UID=VTM;PWD=VTM;DSN=VTM")
'It s Ok    
MsgBox conBO.Connect
MsgBox conBO.Name  
With wrkODBC
     ' Enumerate Properties collection of ODBCDirect
        ' workspace.
        Debug.Print "Properties of " & .Name
        On Error Resume Next

        For Each prpLoop In .Properties
            Debug.Print "    " & prpLoop.Name & " = " & prpLoop
            MsgBox ("    " & prpLoop.Name & " = " & prpLoop)
        Next prpLoop
        On Error GoTo 0
    End With
   
    Set rstTemp = conBO.OpenRecordset("select * from oas_company")
'ODBC called Error !!!!! ?????
    With rstTemp
        Do While .EOF
        MsgBox !CODE
        .MoveNext
        Loop
        .Close
    End With

Thank
zoltixAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
jackgConnect With a Mentor Commented:
okay, apart from james stillmans' observation you are using rstemp without a declaration if you want to use this as a recordset than you will have to declare it. ie dim rstemp as adodb.recordset.  mail back to let me know what data access object you are using and what version of VB.
0
 
James_stillmanCommented:
Could you explain further.

Just by having a quick look and excuse me if I am completley wrong but where you have

do while .eof

Shouldn't you have:

 do while not .EOF

Cheers

James
0
All Courses

From novice to tech pro — start learning today.