lcDataBaseName = 'MSDN' lcMDBDir = 'C:\My Documents\MSDN CD SUBCRIPTION INDEXES\UN-SUPPED' lcMDBName = 'MSDN APRIL CD SUBCRIPTION INDEX.MDB' lnConnHandle = SQLSTRINGCONNECT('DSN=MS Access Database;DBQ='+; lcMDBDir+'\'+lcMDBName+';DefaultDir='+; lcMDBDir+';DriverId=25;FIL=MS Access;MaxBufferSize=2048;'+; 'PageTimeout=5;UID=admin;') Create data (lcDataBaseName) SQLTABLES(lnConnHandle, ['TABLE'], 'myMDB') Select myMDB Scan lcSQL = 'select * from "'+trim(table_name)+'"' lcCursor = chrtran(trim(table_name),' ','_') lcTableName = '_'+lcCursor SQLEXEC(lnConnHandle,lcSQL,lcCursor) Select (lcCursor) Copy to (lcTableName) Add table (lcTableName) Endscan SQLDISCONNECT(lnConnHandle) Modi data
Public oForm oForm = Createobject('myForm') oForm.Show() Define Class myForm As Form Height = 450 Width = 850 DataSession=2 Caption='Show Access Data' Add Object lblAccess As Label With ; Caption = "Access Database", ; Left = 10, Top = 15, Width = 100 Add Object txtMDBlocation As TextBox With ; Left = 112, Top = 12, Width = 520 Add Object cmdBrowse As CommandButton With ; Top = 10, Left = 640, Caption = "Browse", Autosize=.t. Add Object lblTables As Label With ; Caption = "Tables", Left = 20, Top = 40, Width = 40 Add Object lstTables As ListBox With ; Height = 400, Left = 65, Top = 40, Width = 265 Add Object grdShow As Grid With ; Height = 400, Left = 340, Top = 40, Width = 500 Procedure listtables Local lnConnHandle,lcMDB With This.txtMDBlocation If Empty(.Value) Or !File(.Value) Return Endif lcMDB = Trim(.Value) Endwith lnConnHandle = ; Sqlstringconnect("Driver={Microsoft Access Driver (*.mdb)};"+; "Uid=Admin;DBQ="+m.lcMDB) SQLTABLES(m.lnConnHandle, ['TABLE'], 'crsTables') SQLDISCONNECT(m.lnConnHandle) Select crsTables This.lstTables.Clear() Scan This.lstTables.AddItem(crsTables.table_name) Endscan Endproc Procedure txtMDBlocation.LostFocus Thisform.listtables() Endproc Procedure cmdBrowse.Click This.Parent.txtMDBlocation.Value = Getfile('MDB','','',0,'Select Access Database') Thisform.listtables() Endproc Procedure lstTables.InteractiveChange Local lnConnHandle,lcMDB,lcSQL With This.Parent.txtMDBlocation If Empty(.Value) Or !File(.Value) Return Endif lcMDB = Trim(.Value) Endwith lcSQL = 'select * from "'+Trim(This.Value)+'"' lnConnHandle = ; Sqlstringconnect("Driver={Microsoft Access Driver (*.mdb)};"+; "Uid=Admin;DBQ="+m.lcMDB) SQLEXEC(m.lnConnHandle,m.lcSQL,'crsLocal') SQLDISCONNECT(m.lnConnHandle) With This.Parent.grdShow .ColumnCount = -1 .RecordSource = 'crsLocal' Endwith Endproc Enddefine