home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2002 December / INTERNET97.ISO / pc / software / windows / building / xmlspy / setup44.exe / Data1.cab / F1511_DlgImportDB.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-06-19  |  8.3 KB  |  276 lines

  1. VERSION 5.00
  2. Begin VB.Form DlgImportDB 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Import from database"
  5.    ClientHeight    =   4650
  6.    ClientLeft      =   2760
  7.    ClientTop       =   3750
  8.    ClientWidth     =   6030
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   4650
  13.    ScaleWidth      =   6030
  14.    ShowInTaskbar   =   0   'False
  15.    Begin VB.CheckBox CheckEmpty 
  16.       Caption         =   "Include empty elements"
  17.       Height          =   255
  18.       Left            =   2040
  19.       TabIndex        =   18
  20.       Top             =   2400
  21.       Width           =   2055
  22.    End
  23.    Begin VB.CheckBox CheckKeys 
  24.       Caption         =   "Exclude keys"
  25.       Height          =   255
  26.       Left            =   120
  27.       TabIndex        =   17
  28.       Top             =   2400
  29.       Width           =   1695
  30.    End
  31.    Begin VB.CommandButton Command1 
  32.       Caption         =   "Get tables"
  33.       Height          =   255
  34.       Left            =   120
  35.       TabIndex        =   10
  36.       Top             =   4200
  37.       Width           =   1215
  38.    End
  39.    Begin VB.TextBox TxtSelect 
  40.       Height          =   495
  41.       Left            =   2640
  42.       TabIndex        =   9
  43.       Text            =   "SELECT * FROM []"
  44.       Top             =   3120
  45.       Width           =   3255
  46.    End
  47.    Begin VB.ListBox ListTables 
  48.       Height          =   1035
  49.       Left            =   120
  50.       TabIndex        =   6
  51.       Top             =   3120
  52.       Width           =   2295
  53.    End
  54.    Begin VB.Frame Frame1 
  55.       Caption         =   "Source"
  56.       Height          =   2175
  57.       Left            =   120
  58.       TabIndex        =   2
  59.       Top             =   120
  60.       Width           =   3855
  61.       Begin VB.TextBox TxtODBC 
  62.          Height          =   285
  63.          Left            =   480
  64.          TabIndex        =   16
  65.          Text            =   "Text1"
  66.          Top             =   1680
  67.          Width           =   2295
  68.       End
  69.       Begin VB.TextBox TxtADO 
  70.          Height          =   285
  71.          Left            =   480
  72.          TabIndex        =   15
  73.          Text            =   "Text1"
  74.          Top             =   1080
  75.          Width           =   2295
  76.       End
  77.       Begin VB.OptionButton OptODBC 
  78.          Caption         =   "from ODBC connection string"
  79.          Height          =   255
  80.          Left            =   240
  81.          TabIndex        =   14
  82.          Top             =   1440
  83.          Width           =   2535
  84.       End
  85.       Begin VB.OptionButton OptADO 
  86.          Caption         =   "from ADO connection string"
  87.          Height          =   255
  88.          Left            =   240
  89.          TabIndex        =   13
  90.          Top             =   840
  91.          Width           =   2535
  92.       End
  93.       Begin VB.CommandButton BtnBuildODBC 
  94.          Caption         =   "Build"
  95.          Height          =   255
  96.          Left            =   2880
  97.          TabIndex        =   12
  98.          Top             =   1680
  99.          Width           =   855
  100.       End
  101.       Begin VB.CommandButton BtnBuild 
  102.          Caption         =   "Build"
  103.          Height          =   255
  104.          Left            =   2880
  105.          TabIndex        =   11
  106.          Top             =   1080
  107.          Width           =   855
  108.       End
  109.       Begin VB.CommandButton BtnBrowse 
  110.          Caption         =   "Browse"
  111.          Height          =   255
  112.          Left            =   2880
  113.          TabIndex        =   5
  114.          Top             =   480
  115.          Width           =   855
  116.       End
  117.       Begin VB.TextBox TxtFile 
  118.          Height          =   285
  119.          Left            =   480
  120.          TabIndex        =   4
  121.          Top             =   480
  122.          Width           =   2295
  123.       End
  124.       Begin VB.OptionButton OptAccessFile 
  125.          Caption         =   "from MSAccess file"
  126.          Height          =   255
  127.          Left            =   240
  128.          TabIndex        =   3
  129.          Top             =   240
  130.          Width           =   2535
  131.       End
  132.    End
  133.    Begin VB.CommandButton CancelButton 
  134.       Caption         =   "Cancel"
  135.       Height          =   375
  136.       Left            =   4680
  137.       TabIndex        =   1
  138.       Top             =   600
  139.       Width           =   1215
  140.    End
  141.    Begin VB.CommandButton OKButton 
  142.       Caption         =   "Import"
  143.       Height          =   375
  144.       Left            =   4680
  145.       TabIndex        =   0
  146.       Top             =   120
  147.       Width           =   1215
  148.    End
  149.    Begin VB.Label Label2 
  150.       Caption         =   "Query statement"
  151.       Height          =   255
  152.       Left            =   2640
  153.       TabIndex        =   8
  154.       Top             =   2880
  155.       Width           =   2055
  156.    End
  157.    Begin VB.Label Label1 
  158.       Caption         =   "Tables in database"
  159.       Height          =   255
  160.       Left            =   120
  161.       TabIndex        =   7
  162.       Top             =   2880
  163.       Width           =   2295
  164.    End
  165. Attribute VB_Name = "DlgImportDB"
  166. Attribute VB_GlobalNameSpace = False
  167. Attribute VB_Creatable = False
  168. Attribute VB_PredeclaredId = True
  169. Attribute VB_Exposed = False
  170. Public bOK As Boolean
  171. Option Explicit
  172. Private Sub BtnBrowse_Click()
  173.     Dim objDlg
  174.     Set objDlg = CreateObject("MSComDlg.CommonDialog")
  175.     objDlg.ShowOpen
  176.     If Len(objDlg.FileName) > 0 Then
  177.         TxtFile.Text = objDlg.FileName
  178.     End If
  179. End Sub
  180. Private Sub BtnBuild_Click()
  181.     Dim objADO As DataLinks
  182.     Set objADO = CreateObject("DataLinks")
  183.     If Not (objADO Is Nothing) Then
  184.         Dim objConn As Connection
  185.         Set objConn = objADO.PromptNew
  186.         TxtADO.Text = objConn.ConnectionString
  187.     End If
  188. End Sub
  189. Private Sub BtnBuildODBC_Click()
  190.     Dim objDB As DBEngine
  191.     Set objDB = CreateObject("DAO.DBEngine.36")
  192.     If Not (objDB Is Nothing) Then
  193.         Dim objWS As DAO.Workspace
  194.         Set objWS = objDB.CreateWorkspace("", "Build", "", DAO.WorkspaceTypeEnum.dbUseODBC)
  195.         
  196.         Dim objConnection As DAO.Connection
  197.         Dim strName As String
  198.         strName = ""
  199.         
  200.         On Error Resume Next
  201.         Set objConnection = objWS.OpenConnection(strName, dbDriverPrompt)
  202.         
  203.         If Not (objConnection Is Nothing) Then
  204.             TxtODBC = objConnection.Connect
  205.         End If
  206.     End If
  207. End Sub
  208. Private Sub CancelButton_Click()
  209.     Hide
  210. End Sub
  211. Private Sub Command1_Click()
  212.     Dim objImpSettings As DatabaseConnection
  213.     Set objImpSettings = objSpy.GetDatabaseSettings
  214.     'set DatabaseConnection properties to dialog controls
  215.     If OptAccessFile.Value = True Then
  216.         objImpSettings.File = TxtFile.Text
  217.     End If
  218.     If OptADO.Value = True Then
  219.         objImpSettings.ADOConnection = TxtADO.Text
  220.     End If
  221.     If OptODBC.Value = True Then
  222.         objImpSettings.ODBCConnection = TxtODBC.Text
  223.     End If
  224.     'objImpSettings.ExcludeKeys = CheckKeys.Value
  225.     'objImpSettings.IncludeEmptyElements = CheckEmpty.Value
  226.     ListTables.Clear
  227.     Dim objList As ElementList
  228.     Dim objItem As ElementListItem
  229.     On Error GoTo ErrorHandler
  230.     Set objList = objSpy.GetDatabaseTables(objImpSettings)
  231.     For Each objItem In objList
  232.         ListTables.AddItem objItem.Name
  233.     Next
  234.     Exit Sub
  235. ErrorHandler:
  236.     CheckForError
  237. End Sub
  238. Private Sub Form_Activate()
  239.     OptAccessFile.Value = True
  240.     UpdateSourceGrp
  241.     bOK = False
  242. End Sub
  243. Private Sub OKButton_Click()
  244.     bOK = True
  245.     Hide
  246. End Sub
  247. Private Sub OptADO_Click()
  248.     UpdateSourceGrp
  249. End Sub
  250. Private Sub OptAccessFile_Click()
  251.     UpdateSourceGrp
  252. End Sub
  253. Private Sub UpdateSourceGrp()
  254.     TxtFile.Enabled = False
  255.     BtnBrowse.Enabled = False
  256.     TxtADO.Enabled = False
  257.     BtnBuild.Enabled = False
  258.     TxtODBC.Enabled = False
  259.     BtnBuildODBC.Enabled = False
  260.     If OptAccessFile.Value = True Then
  261.         TxtFile.Enabled = True
  262.         BtnBrowse.Enabled = True
  263.     End If
  264.     If OptADO.Value = True Then
  265.         TxtADO.Enabled = True
  266.         BtnBuild.Enabled = True
  267.     End If
  268.     If OptODBC.Value = True Then
  269.         TxtODBC.Enabled = True
  270.         BtnBuildODBC.Enabled = True
  271.     End If
  272. End Sub
  273. Private Sub OptODBC_Click()
  274.     UpdateSourceGrp
  275. End Sub
  276.