1

Konu: MDB Browser

Cihan sormustu baska ihtiyaci olanlar olabilir diye paylastim

Visual Fox Pro
*!* Author Cetin BASOZ

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
http://www.soykansoft.com/images/twitter.jpghttp://www.soykansoft.com/images/wp.jpg