⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 odbcdirect.frm

📁 《VB6数据库开发指南》所有的例程的源码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Chapter 6.6 Example"
   ClientHeight    =   3585
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5325
   BeginProperty Font 
      Name            =   "Courier"
      Size            =   9.75
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3585
   ScaleWidth      =   5325
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin VB.TextBox txtProperties 
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2385
      Left            =   90
      Locked          =   -1  'True
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   3
      Top             =   330
      Width           =   5115
   End
   Begin VB.CommandButton cmdOpen 
      Caption         =   "&Open DSN"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   525
      Left            =   2490
      TabIndex        =   2
      Top             =   2880
      Width           =   1245
   End
   Begin VB.CommandButton cmdClose 
      Caption         =   "&Close"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   525
      Left            =   3960
      TabIndex        =   0
      Top             =   2880
      Width           =   1245
   End
   Begin VB.Label lblTables 
      Caption         =   "No information available"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   1
      Top             =   60
      Width           =   4185
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim conTemp As Connection

Private Sub cmdClose_Click()
    End
End Sub

Private Sub cmdOpen_Click()
    'Let's create a Connection object. This line will force
    'the ODBC driver to prompt the user.
    'The ODBCDirect Connection object is identical, in terms of
    'DAO object hierarchy, to the Database object.
    On Error Resume Next
    Set conTemp = Workspaces(0).OpenConnection("", , False, "ODBC;")
    If Err Then
        Exit Sub
    End If
    'If open, let's get the TableDefs from the Database
    'property of the Connection object.
    If IsObject(conTemp) Then
        'Since the Connection object does not support a
        'Properties collection, we must iterate through
        'each property manually.
        lblTables = "Information  - ODBCDirect connection to " & conTemp.Name & ":"
        With conTemp
            txtProperties = "Connect           " & .Connect
            ' Property actually returns a Database object.
            txtProperties = txtProperties & vbCrLf & _
                "Database[.Name]:  " & .Database.Name
            txtProperties = txtProperties & vbCrLf & _
                "Name:             " & .Name
            txtProperties = txtProperties & vbCrLf & _
                "QueryTimeout:     " & .QueryTimeout
            txtProperties = txtProperties & vbCrLf & _
                "RecordsAffected:  " & .RecordsAffected
            txtProperties = txtProperties & vbCrLf & _
                "StillExecuting:   " & .StillExecuting
            txtProperties = txtProperties & vbCrLf & _
                "Transactions:     " & .Transactions
            txtProperties = txtProperties & vbCrLf & _
                "Updatable:        " & .Updatable
        End With
    End If
End Sub

Private Sub Form_Load()
    'Notice the dbUseODBC parameter; this determines that DBEngine
    'will create an ODBCDirect workspace by default.
    DBEngine.DefaultType = dbUseODBC
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -