Hi Bill,

This bit of code works for databases where the objects have not been made
visible in the remote database

Declare sub main

Sub main

Dim iDbms as integer
Dim iHstmt as integer
iDbms = Server_connect("ODBC","DSN=TestODBC;DLG=0")

If iDbms > 0 then
        
        iHstmt = Server_Execute(iDbms,"Select * From mSysObjects where type
= 1")

        if iHstmt > 0 then
                Server iHstmt Fetch Into "Temp"

                Browse * from Temp
        End if
End if

End sub



Regards

Martin


-----Original Message-----
From: Bill Thoen [mailto:[EMAIL PROTECTED] 
Sent: 25 February 2005 18:13
To: MapInfo-L
Subject: Re: MI-L Opening Tables from Access with MapBasic

Never mind; problem solved. It was a read permission issue. To get around
it, I had to open the database, select the Tools / Options menu command
and on the General tab, check "System Objects" in the Show group. Then I
chose Tools / Security / User and Group permisssions, and select the now
visible MSysObjects table and check "Read Data."

Now MapBasic can open this table and see what tables are in the Access 
database. You can do it directly like so:

Dim sDB As String
  Close All
  sDB = ApplicationDirectory$()+"Sample.mdb"
  Register Table sDB Type "Access" Table "MSysObjects"
    Into ApplicationDirectory$()+"test.tab"
  Open Table ApplicationDirectory$()+"test.tab" As TEST
  Select Name From TEST where Type = 1 into TABS
  Browse * from TABS

or you can use ODBC like so:

Server Link Table "SELECT Name FROM MSysObjects WHERE Type=1;"
Using "DSN=MS Access Database;DBQ=c:\tmp\sample.mdb;UID=ADMIN"
toolkit "ODBC"
Into "Test" File "C:\My Documents\Test.TAB"

(be sure to close the server connection when you're done.)

There must still be another way to list tables in an Access databse even 
if read permission on MSysObjects is turned off, because the MapInfo 
interface to Access can do it. But if that's not done through some API 
accessible to MapBasic, then I guess the above method will work as long as 
you set the permissions first.

- Bill Thoen





---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 15433






---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 15435

Reply via email to