If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Dynamically Link MySQL Tables at Runtime

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-28-04, 19:48
mmaru mmaru is offline
Registered User
 
Join Date: Jun 2004
Posts: 2
Dynamically Link MySQL Tables at Runtime

While I was reading Access Cookbook by Ken Getz, Paul Litwin & Andy Baron found a code that allows user at log-in time to Dynamically Link SQL Server Tables at Runtime. I modified the code hoping it will work for MySQL too. I am getting the following error:

3170: Couldn’t find installable ISAM.


Private Sub cmdConnect_Click()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim rst As DAO.Recordset
Dim strServer As String
Dim strDB As String
Dim strTable As String
Dim strconnect As String
Dim strMsg As String
Dim userName As String
Dim passWord As String


userName = Me!txtUser
passWord = Me!txtPwd

On Error GoTo HandleErr

' Build base authentication strings
Call MySQL_Connection(userName, passWord)
strconnect = strconnectMySQL
' Get rid of old links, if any
'Call DeleteLinks

' Create recordset to obtain server, database and table names
Set db = CurrentDb
Set rst = db.OpenRecordset("tblSQLTables", dbOpenSnapshot)
If rst.EOF Then
strMsg = "There are no tables listed in tblSQLTables."
GoTo ExitHere
End If

' Walk through the recordset and create the links
Do Until rst.EOF
strServer = rst!SQLServer
strDB = rst!SQLDatabase
strTable = rst!SQLTable
' Create a new TableDef object
Set tdf = db.CreateTableDef(strTable)
' Set the Connect property to establish the link
tdf.Connect = strconnect & _
"Server=" & strServer & _
";Database=" & strDB & ";"
tdf.SourceTableName = strTable
' Append to the database's TableDefs collection
db.TableDefs.Append tdf
tdf.RefreshLink
rst.MoveNext
Loop

strMsg = "Tables linked successfully."

rst.Close
Set rst = Nothing
Set tdf = Nothing
Set db = Nothing

ExitHere:
MsgBox strMsg, , "Link SQL Tables"
Exit Sub

HandleErr:
Select Case Err
Case Else
strMsg = Err & ": " & Err.Description
Resume ExitHere
End Select
End Sub

Your help if very much appreciated.

Maru
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On