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

📄 dataconfig.frm

📁 现阶段很多图书租赁店仍然使用手工方式管理
💻 FRM
字号:
VERSION 5.00
Begin VB.Form DataConfig 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "配置数据库"
   ClientHeight    =   3090
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Exit 
      Caption         =   "退出"
      Height          =   495
      Left            =   2880
      TabIndex        =   3
      Top             =   2040
      Width           =   975
   End
   Begin VB.CommandButton GoLogin 
      Caption         =   "确定"
      Height          =   495
      Left            =   1560
      TabIndex        =   2
      Top             =   2040
      Width           =   1095
   End
   Begin VB.TextBox DsnName 
      Height          =   615
      Left            =   1560
      TabIndex        =   1
      Top             =   600
      Width           =   2655
   End
   Begin VB.Label Label1 
      Caption         =   "请输入计算机上的DSN名称"
      Height          =   495
      Left            =   240
      TabIndex        =   0
      Top             =   720
      Width           =   1095
   End
End
Attribute VB_Name = "DataConfig"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim LogStatus As String '判断登录文件是否存在
Dim DBstatus As Integer '判断数据库连接是否成功,1为成功,其值由testDb函数返回
Private Function checkLogFile() '检查登录文件,若存在则返回上次登录的DSN名,否则返回失败字符串log file not existed。登录文件位置位于C:\下面
Dim fso, tf, ts, DsnName
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.fileexists("c:\BookStoreLog.ini") = True Then
Set tf = fso.getfile("c:\BookStoreLog.ini")
Set ts = tf.openastextstream(1, -2)
DsnName = ts.readline
checkLogFile = DsnName
Else
checkLogFile = "Not existed"
End If
End Function
Private Sub saveLogFile(DsnFile As String) '保存登录文件,以便下次访问
Dim fso, tf
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile("c:\BookStoreLog.ini", True)
tf.WriteLine (DsnFile)
tf.Close

End Sub

Private Sub Exit_Click()
End
End Sub

Private Sub Form_Load()
LogStatus = checkLogFile  '检查登录文件是否存在
If LogStatus <> "Not existed" Then DsnName.Text = LogStatus '存在文件,返回DSN名到文本框
End Sub

Private Sub GoLogin_Click()
If DsnName = "" Then
MsgBox "必须填写DSN名称"
Else
     '设置连接字符串Str
     Str = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=" & DsnName.Text & ";"
     DBstatus = testDb(Str)  '检查数据库连接是否正常,testDb在标准模块内
     If DBstatus = 1 And CurrentStatus = 0 Then  '数据库连接成功,保存登录文件,如果当前用户登录后修改数据库连接,则到主窗体,否则加载登录窗体
     saveLogFile DsnName
     login.Show
     ElseIf DBstatus = 1 And CurrentStatus = 1 Then
     main.Show
     End If
     Unload Me
End If
End Sub

⌨️ 快捷键说明

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