LOTUS CONNECTORS
Sub Initialize Dim con As New ODBCConnection Dim msg As String tables = con.ListTables("ATDC") If con.GetError <> DBstsSuccess Then Messagebox con.GetExtendedErrorMessage,, _ con.GetErrorMessage Exit Sub End If msg = "ATDB contains the following tables:" & Chr(10) For n% = Lbound(tables) To Ubound(tables) msg = msg & Chr(10) & tables(n%) Next Messagebox msg,, "Tables for ATDB" con.Disconnect End Sub
Sub Initialize Dim con As New ODBCConnection Dim dsn As String Dim msg As String On Error Goto errorHandler getDsn: dsn = Inputbox("ODBC data source name", "DSN") If dsn = "" Then Exit Sub con.ConnectTo(dsn) tables = con.ListTables(dsn) msg = dsn & " contains the following tables: _ & Chr(10) For n% = Lbound(tables) To Ubound(tables) msg = msg & Chr(10) & tables(n%) Next Messagebox msg,, "Tables for " & dsn con.Disconnect Exit Sub errorHandler: If con.GetError = DBstsODBC Then Messagebox "Enter correct DSN or nothing",, _ "Bad data source name" Resume getDsn Else Messagebox con.GetExtendedErrorMessage,, _ con.GetErrorMessage Exit Sub End If End Sub
Sub Initialize Dim con As New ODBCConnection Dim qry As New ODBCQuery Dim result As New ODBCResultSet On Error Goto errorHandler Set qry.Connection = con Set result.Query = qry con.ConnectTo("ATDB") REM This causes an error during result.Execute qry.SQL = _ ("SELECT * FROM STUDENTS WHERE ?STUDENT_ID? = ?1234?") result.Execute Exit Sub errorHandler: If con.GetError <> DBstsSuccess Then Messagebox con.GetErrorMessage,, _ WhatIsError(con.Error) Elseif qry.GetError <> DBstsSuccess Then Messagebox qry.GetErrorMessage,, _ WhatIsError(qry.Error) Elseif result.GetError <> DBstsSuccess Then Messagebox result.GetErrorMessage,, _ WhatIsError(result.Error) End If Exit Sub End Sub
Function WhatIsError(number As Integer) As String Select Case number Case DBSTSACCS : WhatIsError = "DBSTSACCS" Case DBSTSAHVR : WhatIsError = "DBSTSAHVR" Case DBSTSBADP : WhatIsError = "DBSTSBADP" Case DBSTSCANF : WhatIsError = "DBSTSCANF" Case DBSTSCARR : WhatIsError = "DBSTSCARR" Case DBSTSCCON : WhatIsError = "DBSTSCCON" Case DBSTSCNVD : WhatIsError = "DBSTSCNVD" Case DBSTSCNVR : WhatIsError = "DBSTSCNVR" Case DBSTSCOAR : WhatIsError = "DBSTSCOAR" Case DBSTSCPAR : WhatIsError = "DBSTSCPAR" Case DBSTSCXIN : WhatIsError = "DBSTSCXIN" Case DBSTSENTR : WhatIsError = "DBSTSENTR" Case DBSTSEOFD : WhatIsError = "DBSTSEOFD" Case DBSTSFAIL : WhatIsError = "DBSTSFAIL" Case DBSTSHSTMT : WhatIsError = "DBSTSHSTMT" Case DBSTSILLG : WhatIsError = "DBSTSILLG" Case DBSTSINTR : WhatIsError = "DBSTSINTR" Case DBSTSINVC : WhatIsError = "DBSTSINVC" Case DBSTSINVR : WhatIsError = "DBSTSINVR" Case DBSTSMEMF : WhatIsError = "DBSTSMEMF" Case DBSTSNAFI : WhatIsError = "DBSTSNAFI" Case DBSTSNCOJ : WhatIsError = "DBSTSNCOJ" Case DBSTSNCOL : WhatIsError = "DBSTSNCOL" Case DBSTSNCON : WhatIsError = "DBSTSNCON" Case DBSTSNODA : WhatIsError = "DBSTSNODA" Case DBSTSNOEX : WhatIsError = "DBSTSNOEX" Case DBSTSNQOJ : WhatIsError = "DBSTSNQOJ" Case DBSTSNUNQ : WhatIsError = "DBSTSNUNQ" Case DBSTSODBC : WhatIsError = "DBSTSODBC" Case DBSTSPMIS : WhatIsError = "DBSTSPMIS" Case DBSTSRCHG : WhatIsError = "DBSTSRCHG" Case DBSTSRDON : WhatIsError = "DBSTSRDON" Case DBSTSROWD : WhatIsError = "DBSTSROWD" Case DBSTSRUNC : WhatIsError = "DBSTSRUNC" Case DBSTSSNFD : WhatIsError = "DBSTSSNFD" Case DBSTSUBLE : WhatIsError = "DBSTSUBLE" Case DBSTSUNIM : WhatIsError = "DBSTSUNIM" End Select Mid(WhatIsError, 3, 5) = "sts" End Function