VB attaching SQL database

Source: Internet
Author: User

:

The Code is as follows:

Public m As String, l As String, strdata As String
Private Sub commandementclick ()
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 "appended! "," VB additional Database"
Exit Sub
DataErr:
MsgBox Err. Description, "VB additional Database"
End Sub
Private Sub Command2_Click ()
With CommonDialog1
. InitDir = "E: mrfl File Modified on the ASP disc"
. 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

<

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.