📄 frmcreatedata.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form FrmCreateData
BorderStyle = 1 'Fixed Single
Caption = "创建数据库"
ClientHeight = 3480
ClientLeft = 45
ClientTop = 330
ClientWidth = 6135
Icon = "FrmCreateData.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3480
ScaleWidth = 6135
StartUpPosition = 2 '屏幕中心
Begin ToolForSQL2000.LCommandButton Command1
Height = 375
Left = 4080
TabIndex = 14
Top = 600
Width = 1695
_ExtentX = 2990
_ExtentY = 661
Caption = "创建"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
FontSize = 9
DownBorderColor = 8421504
RightBorderColor= 8421504
PictureHeight = 15
PictureWidth = 15
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 240
Top = 1440
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.ListBox List1
Height = 2580
Left = 120
TabIndex = 3
Top = 4920
Width = 9495
End
Begin VB.Frame Frame1
Height = 3255
Left = 120
TabIndex = 0
Top = 120
Width = 5895
Begin ToolForSQL2000.LCommandButton Command2
Height = 375
Left = 3960
TabIndex = 15
Top = 960
Width = 1695
_ExtentX = 2990
_ExtentY = 661
Caption = "取消"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
FontSize = 9
DownBorderColor = 8421504
RightBorderColor= 8421504
PictureHeight = 15
PictureWidth = 15
End
Begin VB.CheckBox Check1
Caption = "SQL Server默认路径"
Height = 255
Left = 120
TabIndex = 12
Top = 2880
Value = 1 'Checked
Width = 2415
End
Begin VB.ComboBox ComboSQLServerName
Height = 300
Left = 1500
TabIndex = 10
Top = 360
Width = 2175
End
Begin VB.TextBox TextLoadName
Height = 300
Left = 1500
TabIndex = 7
Text = "sa"
Top = 840
Width = 2175
End
Begin VB.TextBox TextLoadPassword
Height = 300
IMEMode = 3 'DISABLE
Left = 1500
PasswordChar = "*"
TabIndex = 6
Text = "manager"
Top = 1320
Width = 2175
End
Begin VB.TextBox TextPath
Enabled = 0 'False
Height = 300
Left = 660
TabIndex = 5
Top = 2400
Width = 4755
End
Begin VB.TextBox ComboDName
Height = 300
Left = 1500
MaxLength = 50
TabIndex = 1
Top = 1800
Width = 2175
End
Begin ToolForSQL2000.LCommandButton CommandPath
Height = 300
Left = 5400
TabIndex = 16
Top = 2400
Width = 300
_ExtentX = 529
_ExtentY = 529
Caption = "┈"
Enabled = 0 'False
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
FontSize = 9
DownBorderColor = 8421504
RightBorderColor= 8421504
PictureHeight = 15
PictureWidth = 15
End
Begin VB.Label LabelPath
Caption = "c:\"
Height = 255
Left = 3960
TabIndex = 13
Top = 2880
Visible = 0 'False
Width = 1815
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "服务器名或IP:"
Height = 180
Index = 0
Left = 180
TabIndex = 11
Top = 420
Width = 1260
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "用户名:"
Height = 180
Index = 1
Left = 600
TabIndex = 9
Top = 900
Width = 840
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "口令:"
Height = 180
Index = 2
Left = 900
TabIndex = 8
Top = 1380
Width = 540
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "路径:"
Height = 180
Index = 4
Left = 120
TabIndex = 4
Top = 2460
Width = 540
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "数据库名:"
Height = 180
Index = 3
Left = 540
TabIndex = 2
Top = 1860
Width = 900
End
End
End
Attribute VB_Name = "FrmCreateData"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Rs As New adodb.Recordset
Dim SqlString As String
Private Sub Check1_Click()
Select Case Check1.Value
Case 0
TextPath.Text = ""
TextPath.Enabled = True
CommandPath.Enabled = True
Case 1
TextPath.Text = LabelPath.Caption
TextPath.Enabled = False
CommandPath.Enabled = False
End Select
End Sub
Private Sub Command1_Click()
On Error GoTo errd
CnnData adUseClient, "sqloledb", ComboSQLServerName.Text, "master", TextLoadName.Text, TextLoadPassword.Text, adPromptNever, 15
'Sqlstr = "Create DataBase " + ComboDName.Text + " WITH LOCATION =E:\Oracle\oradata\tempdb1\system01.dbf"
'Sqlstr = ""
'Sqlstr = Sqlstr & "CREATE DATABASE " & ComboDName.Text
'Sqlstr = Sqlstr & " ON "
'Sqlstr = Sqlstr & "(NAME='" & ComboDName.Text & "_dat'," '执行文件名
'Sqlstr = Sqlstr & "FILENAME='" & Text1.Text & ComboDName.Text & "_dat.mdf',"
'Sqlstr = Sqlstr & "SIZE=10MB," '文件的大小
'Sqlstr = Sqlstr & "MAXSIZE=50MB," '可以增长到的最大大小
'Sqlstr = Sqlstr & "FILEGROWTH=5MB)" '文件的增长增量
'Sqlstr = Sqlstr & " LOG ON "
' Sqlstr = Sqlstr & "(NAME='" & ComboDName.Text & "_log',"
' Sqlstr = Sqlstr & "FILENAME='" & Text1.Text & ComboDName.Text & "_log.ldf',"
' Sqlstr = Sqlstr & "SIZE=5MB,"
' Sqlstr = Sqlstr & "MAXSIZE=25MB,"
' Sqlstr = Sqlstr & "FILEGROWTH=5MB)"
SqlString = Sqlstr(ComboDName.Text, TextPath.Text)
Cns.Execute SqlString
EXT
MsgBox "数据库 " & ComboDName.Text & " 创建成功!"
Unload Me
errd:
If Err.Number <> 0 Then
MsgBox "错误代码:" & Err.Number & vbCrLf & Err.Description
Err.Clear
EXT
End If
End Sub
Private Sub Command2_Click()
EXT
Unload Me
End Sub
Private Sub CommandPath_Click()
TextPath.Text = OpenPath(Me.hwnd, "选择文件路径", "")
If Len(TextPath.Text) > 0 Then
If VBA.Right(TextPath.Text, 1) <> "\" Then
TextPath.Text = TextPath.Text & "\"
End If
End If
End Sub
Private Sub Form_Resize()
'SetTopMostWindow Me.hwnd, True '使窗体位于最顶端
End Sub
Sub EXT()
On Error GoTo errE
Cns.Close
Rs.Close
errE:
If Err.Number <> 0 Then
Err.Clear
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -