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

📄 frmconfig.frm

📁 网路设备资产管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form FrmConfig 
   Caption         =   "系统参数配置"
   ClientHeight    =   3360
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   5325
   Icon            =   "FrmConfig.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3360
   ScaleWidth      =   5325
   StartUpPosition =   1  '所有者中心
   Begin VB.CommandButton cmdSave 
      Caption         =   "保存"
      Height          =   495
      Left            =   1800
      TabIndex        =   9
      Top             =   2760
      Width           =   1455
   End
   Begin VB.Frame Frame1 
      Caption         =   "数据库连接"
      Height          =   2535
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   5055
      Begin VB.TextBox txtdbname 
         Height          =   390
         Left            =   1560
         TabIndex        =   8
         Top             =   1800
         Width           =   2175
      End
      Begin VB.TextBox txtdbpassword 
         Height          =   390
         Left            =   1560
         TabIndex        =   7
         Top             =   1320
         Width           =   2175
      End
      Begin VB.TextBox txtdbusername 
         Height          =   390
         Left            =   1560
         TabIndex        =   6
         Top             =   840
         Width           =   2175
      End
      Begin VB.TextBox txtdbaddr 
         Height          =   390
         Left            =   1560
         TabIndex        =   5
         Top             =   360
         Width           =   2175
      End
      Begin VB.Label Label4 
         Caption         =   "用户名:"
         Height          =   255
         Left            =   480
         TabIndex        =   4
         Top             =   960
         Width           =   975
      End
      Begin VB.Label Label3 
         Caption         =   "数据库:"
         Height          =   255
         Left            =   480
         TabIndex        =   3
         Top             =   1920
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "密码:"
         Height          =   255
         Left            =   480
         TabIndex        =   2
         Top             =   1440
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "主机:"
         Height          =   255
         Left            =   480
         TabIndex        =   1
         Top             =   480
         Width           =   975
      End
   End
End
Attribute VB_Name = "FrmConfig"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'****************************************************************************
'人人为我,我为人人
'枕善居收藏整理
'发布日期:2007/09/25
'描    述:江苏大学网络信息中心网络管理系统 - v1.0 Beta
'网    站:http://www.Mndsoft.com/  (VB6源码博客)
'网    站:http://www.VbDnet.com/   (VB.NET源码博客,主要基于.NET2005)
'e-mail  :Mndsoft@163.com
'e-mail  :Mndsoft@126.com
'OICQ    :88382850
'          如果您有新的好的代码别忘记给枕善居哦!
'****************************************************************************

Public result As Boolean


Private Sub cmdSave_Click()

Dim FileName As String
FileName = App.Path & "\config.ini"

result = False

If Trim(txtdbaddr) = "" Then
   MsgBox "主机不能为空!", vbOKOnly + vbExclamation, "警告"
   txtdbaddr.SetFocus
   Exit Sub
End If

If Trim(txtdbusername) = "" Then
   MsgBox "用户名不能为空!", vbOKOnly + vbExclamation, "警告"
   txtdbusername.SetFocus
   Exit Sub
End If

If Trim(txtdbname) = "" Then
   MsgBox "数据库不能为空!", vbOKOnly + vbExclamation, "警告"
   txtdbname.SetFocus
   Exit Sub
End If


'对连接进行测试
Dim testcnn As ADODB.Connection

testConnectString = "Driver={SQL Server};Server=" & txtdbaddr & ";Uid=" & txtdbusername & ";Pwd=" & txtdbpassword & ";Database=" & txtdbname


On Error GoTo ExcuteSQL_Error

Set testcnn = New ADODB.Connection
testcnn.ConnectionTimeout = 5
    testcnn.Open testConnectString
    
    
    
re = SetIni(FileName, "database", "dbaddr", Trim(txtdbaddr))
re = SetIni(FileName, "database", "dbusername", Trim(txtdbusername))
re = SetIni(FileName, "database", "dbpassword", Trim(txtdbpassword))
re = SetIni(FileName, "database", "dbname", Trim(txtdbname))




    
ExcuteSQL_Exit:
    
    Set testcnn = Nothing
    result = True
    MsgString = "数据库连接正常,配置参数已写入文件!"

    MsgBox MsgString, vbOKOnly + vbExclamation, "提示"
    
    Me.Hide
    Exit Sub

ExcuteSQL_Error:
    MsgString = "数据库连接错误,请检查您的参数配置!错误信息为:" & Err.Description
    MsgBox MsgString, vbOKOnly + vbExclamation, "提示"
    txtdbaddr.SetFocus
    Exit Sub
    
    


End Sub

⌨️ 快捷键说明

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