این برنامه یک بانک اکسس را باز می کند و لیست ان را نمایش می دهد و می تواند ان بانک را به dbf تبدیل کند
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 cmdCreateDb As CommandButton With ;
Top = 10, Left = 700, Caption = "Create VFP Database", ;
Autosize=.T.,Enabled = .F.
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
This.cmdCreateDb.Enabled = .T.
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
Procedure cmdCreateDb.Click
Local lcFileName,lcViewName, lcConnection, lcFrom
lcFileName = Putfile("VFP Db name","MyAccessDb.dbc","DBC")
If Empty(m.lcFileName)
Return
Endif
lcConnection = "Driver={Microsoft Access Driver (*.mdb)};Uid=Admin;DBQ="+;
TRIM(This.Parent.txtMDBlocation.Value)
Create Database (m.lcFileName)
Create Connection accessCn Connstring m.lcConnection
Select crsTables
Scan
lcViewName = Chrtran(Trim(crsTables.table_name),' $','_')
lcFrom = "["+Trim(crsTables.table_name)+"]"
Create Sql View (m.lcViewName) ;
Remote Connection "accessCn" ;
As Select * From &lcFrom
Endscan
Endproc
Enddefine