效果圖:
**如下:
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光碟修改檔案/mr/fl"
.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
list1.additem .filetitle & " " & m
list1.additem strdata & "_log.ldf" & " " & l
else
list1.additem .filetitle & " " & m
list1.additem strdata & "_log.ldf" & " " & l
end if
else
msgbox "請選擇資料檔案!", , "vb附加資料庫"
end if
end with
end sub
private sub list1_click()
label4 = list1.text
end sub
附加資料庫 sql
附加資料庫 sp attach db xxaccountsdb6 e 資料庫 xxaccountsdb6.mdf e 資料庫 xxaccountsdb6 log.ldf gosp attach db xxagentsystem e 資料庫 xxagentsystem.mdf e 資料庫 xxagen...
SQL語句附加還原資料庫
示例下面的示例將 pubs 中的兩個檔案附加到當前伺服器。exec sp attach db dbname n pubs filename1 n c program files microsoft sql server mssql data pubs.mdf filename2 n c progra...
VB連線SQL資料庫的方法
vb使用ado資料庫可以分為有源資料庫和無源資料庫,即是否使用了dsn資料來源,如下例 1 在連線資料庫前首先要在vb選單中 工程 引用 從中選擇 microsoft activex data objects 2.6 library和 microsoft activex data objects r...