Get all tablenames

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

How to list all the tablenames from an Access ODBC connection?




Using Windows 98 SE
Registered PB version : 3.40 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.
Originally posted by cor

How to list all the tablenames from an Access ODBC connection?

Update

The following codes is working for version 3.4 thanks to Codeguru

But now how to list all tables? I have problems to implement the SQLTables command from the ODBC API

Any help is welcome

Code: Select all

;
;Create DSN on the fly  for ODBC
;
; An example by Siegfried Rings (CodeGuru)

#ODBC_ADD_DSN = 1     ; Add Data source
#ODBC_CONFIG_DSN = 2  ; Configure (edit) Data source
#ODBC_REMOVE_DSN = 3  ; Remove Data source

Declare MakeConnection(Driver.s,strAttributes.s)
Declare DeleteConnection(Driver.s,DSN.s)

;example:
Result=Makeconnection("Microsoft Access Driver (*.mdb)","Server=; Description=Description For PurebasicODBC;DSN=PureBasic_DSN;DBQ=p:\cor\purebasic\ontwikkel\aspwizard\eva.mdb;UID=;PWD=;")
;Result=Makeconnection("Microsoft Excel Driver (*.xls)","DSN=Excel_TEST;Description=New_Excel_Data_Source;FileType=Excel97;DBQ=C:\\Telefon.xls;")


MessageRequester("",Str(result),0)
;or delete:
;DeleteConnection("Microsoft Access Driver (*.mdb)","PureBasic_DSN")

End

Procedure MakeConnection(Driver.s,strAttributes.s)
Result=OpenLibrary(1,"ODBCCP32.DLL")
If Result 
lpszDriver.s=Driver
; MessageRequester("Info",strAttributes,0)
MyMemory=AllocateMemory(1,Len(strAttributes))
CopyMemory(@strAttributes,MyMemory,Len(strAttributes))
For L=1 To Len(strAttributes )
If PeekB(MyMemory +l-1)=Asc(";")
  PokeB(MyMemory +l-1,0)
  EndIf
Next L 
Result = CallFunction(1,"SQLConfigDataSource",0,#ODBC_ADD_DSN,lpszDriver.s,MyMemory)
FreeMemory(1)
CloseLibrary(1)
If Result
  ProcedureReturn 1;MessageRequester("Info","DSN Created",0)
EndIf
EndIf
EndProcedure


Procedure DeleteConnection(Driver.s,DSN.s)
Result=OpenLibrary(1,"ODBCCP32.DLL")
If Result 
  lpszDriver.s=Driver
  strAttributes.s = "DSN="+DSN
  Result = CallFunction(1,"SQLConfigDataSource",0,#ODBC_REMOVE_DSN,lpszDriver.s,strAttributes)
  CloseLibrary(1)
  If Result
    ProcedureReturn 1;MessageRequester("Info","DSN Delete",0)
   EndIf
EndIf
EndProcedure 
; ExecutableFormat=Windows
; EOF

Using Windows 98 SE
Registered PB version : 3.40 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Using Windows 98 SE
Registered PB version : 3.40 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Rings.

GetTables() should be a native PureCommand.
Is already on the wishlist.


Its a long way to the top if you wanna .....CodeGuru
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

But before the wishlist is executed, I want to use it :)

Using Windows 98 SE
Registered PB version : 3.40 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Post Reply