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

📄 form1.frm

📁 Visual.Basic.NET实用编程百例-47.6M.zip
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "创建ODBC数据源"
   ClientHeight    =   1530
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4065
   LinkTopic       =   "Form1"
   ScaleHeight     =   1530
   ScaleWidth      =   4065
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command2 
      Caption         =   "删除"
      Height          =   495
      Left            =   2160
      TabIndex        =   1
      Top             =   480
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "创建"
      Height          =   495
      Left            =   480
      TabIndex        =   0
      Top             =   480
      Width           =   1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Const ODBC_ADD_DSN = 1
Private Const ODBC_CONFIG_DSN = 2
Private Const ODBC_REMOVE_DSN = 3
Private Const vbAPINull As Long = 0&

Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" _
                (ByVal hwndParent As Long, _
                ByVal fRequest As Long, _
                ByVal lpszDriver As String, _
                ByVal lpszAttributes As String) _
                As Long

Private Sub Command1_Click()
  Dim intRet As Long
    intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, _
                        "Microsoft Access Driver (*.mdb)" + Chr$(0), _
                        "DSN=test;DBQ=D:\BIBLIO.MDB;DEFAULTDIR=D:\" + Chr$(0))
    '如果要显示对话,可使用Me.Hwnd代替vbAPINull
    
    If intRet Then
        MsgBox "DSN建立成功"
    Else
        MsgBox "DSN建立失败"
    End If
End Sub


Private Sub Command2_Click()
 Dim intRet As Long
    intRet = SQLConfigDataSource(vbAPINull, ODBC_REMOVE_DSN, _
                        "Microsoft Access Driver (*.mdb)" + Chr$(0), _
                        "DSN=test" + Chr$(0))
    If intRet Then
        MsgBox "DSN删除成功"
    Else
        MsgBox "DSN删除失败"
    End If
End Sub

⌨️ 快捷键说明

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