home *** CD-ROM | disk | FTP | other *** search
- 'Connection example
- Dim Con As New Connection
- Dim Qry As New Query
- Dim RS As New ResultSet
- Dim LName As String
-
- 'Connect to your db2 database. An exclamation point is required in front
- 'of the database name.
- If (Con.ConnectTo ("ODBC Data Sources","qe","db2www", "!Db2wwwvd")<>False) Then
- Set Qry.Connection = con
- 'Select the tablename
- Qry.Tablename = "QE.ACTORS"
- 'Specify a SQL statement to run (Optional)
- Qry.Sql = "Select LASTNAME, FIRSTNAME, BIRTHDATE From QE.ACTORS Where LASTNAME Like 'S%'"
- Set RS.Query = Qry
-
- 'If the query was successful
- If ((RS.Execute)<>False) Then
- N = RS.NumColumns
- 'Print the values for the column LASTNAME to the IDE output window
- For i= 1 To Rs.NumRows
- LName = Rs.GetValue("LASTNAME")
- Print LName
- RS.NextRow
- Next
- 'Otherwise let me know that there was a problem connecting
- Else
- Messagebox "The query did not run successfully.", 0, "Query Execution"
- End If
- End If
- 'If I don't disconnect here, I will have trouble reconnecting later.
- CON.DISCONNECT
-