【www.gdgbn.com--php常用代码】
效果图:
代码如下:
Public m As String, l As String, strdata As String
Private Sub Command1_Click()
Dim cn As New ADODB.Connection
On Error GoTo dataErr
cn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;Data Source=zhan;User ID=sa;password=zhan;Initial Catalog=master"
1 cn.Execute ("sp_attach_db @dbname =""" & strdata & """, @filename1 = N" & """" & m & """, @filename2 = N" & """" & l & """")
MsgBox "附加成功!", , "VB附加数据库"
Exit Sub
dataErr:
MsgBox Err.Description, , "VB附加数据库"
End Sub
Private Sub Command2_Click()
With CommonDialog1
.InitDir = "E:ASP光盘修改文件mrfl"
.ShowOpen
If .FileName <> "" Then
Text1 = .FileName
m = .FileName
l = Mid(.FileName, 1, Len(.FileName) - 8) & "Log.LDF"
strdata = Mid(.FileTitle, 1, Len(.FileTitle) - 9)
If List1.ListCount > 0 Then
List1.Clear
&nbs