6 messages in com.mysql.lists.win32RE: connection to DAO.connection fail...| From | Sent On | Attachments |
|---|---|---|
| robert rottermann | 27 Nov 2002 10:05 | |
| robert rottermann | 27 Nov 2002 12:29 | |
| Ed Carp | 27 Nov 2002 12:42 | |
| Dennis Salguero | 27 Nov 2002 14:36 | |
| Ed Carp | 27 Nov 2002 17:54 | |
| Dennis Salguero | 28 Nov 2002 04:30 |
| Subject: | RE: connection to DAO.connection fails usin myodbc![]() |
|---|---|
| From: | Ed Carp (er...@pobox.com) |
| Date: | 11/27/2002 12:42:59 PM |
| List: | com.mysql.lists.win32 |
Unfortunately the the DAO samples I found in the myodbc-FAQ do not work. Neitehr from within Access nor from plain VB. The ADO samples work though.
This is from actual, working code - VB 6.0:
Dim MyDB As Database, MyRS As Recordset
' grab NameStr, ConnectStr from registry NameStr = GetSetting(App.EXEName, "CONNECTION", "NSTR") ConnectStr = GetSetting(App.EXEName, "CONNECTION", "CSTR") If ConnectStr = "" Then ConnectStr = "ODBC;" Debug.Print NameStr Debug.Print ConnectStr MyDBName = "LocalDB.MDB"
' what this code does is connect via ODBC - if that fails, connect to the local database On Error Resume Next Err = 1 While Err <> 0 Err = 0 If ConnectStr <> "" Then Set MyDB = OpenDatabase(NameStr, dbDriverNoPrompt, False, ConnectStr) Else Set MyDB = OpenDatabase(NameStr) End If Debug.Print Err; ": "; Error$ If Err = 3059 Then NameStr = MyDBName ConnectStr = "" Else If Err = 3024 Then End Else NameStr = MyDB.Name ConnectStr = MyDB.Connect End If End If If Err <> 0 Then Pause 5 Wend On Error GoTo 0 If ConnectStr <> "" Then SaveSetting App.EXEName, "CONNECTION", "CSTR", ConnectStr SaveSetting App.EXEName, "CONNECTION", "NSTR", NameStr End If
' at this point, we can do queries, etc. Don't forget to add dbSQLPassThrough, or your SQL will run dog-slow!




