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

📄 add数据库.frm

📁 学生管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form add数据库 
   Caption         =   "Form1"
   ClientHeight    =   4500
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5955
   LinkTopic       =   "Form1"
   ScaleHeight     =   4500
   ScaleWidth      =   5955
   StartUpPosition =   3  '窗口缺省
   Begin VB.Timer Timer1 
      Left            =   4080
      Top             =   2760
   End
   Begin VB.CommandButton Command1 
      Caption         =   "连接"
      Height          =   615
      Left            =   600
      TabIndex        =   6
      Top             =   3000
      Width           =   1815
   End
   Begin VB.TextBox Text3 
      Alignment       =   1  'Right Justify
      Height          =   500
      Left            =   2040
      TabIndex        =   5
      Top             =   2040
      Width           =   1575
   End
   Begin VB.TextBox Text2 
      Alignment       =   1  'Right Justify
      Height          =   500
      Left            =   2160
      TabIndex        =   3
      Top             =   1200
      Width           =   1575
   End
   Begin VB.TextBox Text1 
      Alignment       =   1  'Right Justify
      Height          =   500
      Left            =   2040
      TabIndex        =   1
      Top             =   360
      Width           =   1695
   End
   Begin VB.Label Label3 
      Alignment       =   1  'Right Justify
      Caption         =   "计算机名"
      Height          =   495
      Left            =   240
      TabIndex        =   4
      Top             =   1920
      Width           =   1455
   End
   Begin VB.Label Label2 
      Alignment       =   1  'Right Justify
      Caption         =   "用户名"
      Height          =   495
      Left            =   240
      TabIndex        =   2
      Top             =   1200
      Width           =   1335
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      Caption         =   "数据库名"
      Height          =   495
      Left            =   360
      TabIndex        =   0
      Top             =   360
      Width           =   1215
   End
End
Attribute VB_Name = "add数据库"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private con As New ADODB.Connection
Private rs As New ADODB.Recordset
Private STR, SMDF, SMDFS, SLDF, SLDFS, ODBC_str As String
Private UserName As String
Private UserPwd As String
Dim rs1222 As ADODB.Recordset
Dim connter As Integer     '定义一个整型变量
Dim sql, workarea(4600) As String
Dim char As Byte
Dim Intext As String
Dim Intexts As String
Dim strtemp As String * 200
Dim StrName As String * 256
Dim Computer_str  As String * 256
Dim db_str As String * 256
Dim Paths As String * 256

Dim YWJ, MWJ, L, L1 As String, s As String * 1, ASCIIN, i As Integer
    Dim X As Integer
'提取计算机名和用户名
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long



Private Sub Command1_Click()
 If con.State <> 0 Then con.Close
  con.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa"
        con.Open

 Set rs = New ADODB.Recordset
 STR = "EXEC sp_attach_db @dbname = N'" + Trim(db_str) + "', @filename1 = N'" + SMDF + "', @filename2 = N'" + SLDF + "'"
      If rs.State <> 0 Then rs.Close
      rs.Open STR, con, 3, 2
             Open (App.Path & "\DataBase.ini") For Output As #1
      Print #1, "Yes"
 Close #1
    MsgBox "数据库安装成功!!", , "系统提示"
  登陆框.Show
  Me.Hide

End Sub

Private Sub Form_Load()
'Dim ss As Data
'Dim dd As Integer
'shockwavefalsh1.movie = App.Path & "\swf\sss.swf"
'If GetSetting(appnme = "this", section:="user", Key:="time") Then
'MsgBox "尊敬的用户,你好!你还没有注册软件,从先开始,你的试用期为30天!"
'SaveSetting appname:="this", section:="user", Key:="time", setting:=Data
'Else
'ss = GetSetting(appnme = "this", section:="user", Key:="time")
'dd = Data - ss
'If dd > 30 Then
'MsgBox "你的试用期已到"
'Unload Me
'Else
'MsgBox "你现在还没有注册本软件,试用期为" & 30 - dd & "天"
'End If
'End If
'Timer1.Enabled = True
If con.State <> 0 Then con.Close
con.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa"
con.Open

Set rs1222 = rs1
 rs1.Open "select * from master.dbo.sysdatabases  where name ='xscj'", con, 3, 1
 
 If Not rs1.EOF Then
   
    登陆框.Show
Unload Me
Else
Dim L As Integer
Open (App.Path & "\DataBase.ini") For Input As #1
    Line Input #1, Intexts
Close #1
If Intexts <> "Yes" Then
GetComputerName Computer_str, 255
Paths = Left(strtemp, L) & "\sqlsrv32.dll"
       Open (App.Path & "\Setup.ini") For Input As #1
               Line Input #1, Intext
               Line Input #1, Intext                                       '读入数据库名称
               db_str = Mid(Intext, 9, Len(Intext) - 9)
               Line Input #1, Intext
               UserName = Mid(Intext, 11, Len(Intext) - 11)                '读入登录用户名信息
               Line Input #1, Intext
               UserPwd = Mid(Intext, 10, Len(Intext) - 10)                 '读入用户密码信息
               Line Input #1, Intext
               SMDFS = Intext
               SMDF = App.Path & "\" & Mid(Intext, 10, Len(Intext) - 10)   '读入MDF文件名称
               Line Input #1, Intext
               SLDFS = Intext
               SLDF = App.Path & "\" & Mid(Intext, 10, Len(Intext) - 10)   '读入LDF文件名称
       Close #1
    GetUserName StrName, 255
    Text1.text = Trim(db_str)
    Text2.text = Trim(UserName)
   Text3.text = Trim(Computer_str)
 ElseIf Intexts = "Yes" Then
MsgBox "数据库已添加在服务器中"
rs1.Close

登陆框.Show
Unload Me
End If
End If
End Sub

⌨️ 快捷键说明

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