attach mdf file to sql server 2005 using vb.net

Posted by Rohanphavde under VB.NET on 1/21/2014 | Points: 10 | Views : 1317 | Status : [Member] | Replies : 2
attach mdf file to sql server 2005 using vb.net




Responses

Posted by: kgovindarao523-21772 on: 1/21/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

Try like this.

First thing, you'll need to have installed SQL Express.
Dim cnnConnection As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=" & "YOUR-.mdf-FILE-PATH" & ";Integrated Security=True;Database='" & YOUR-DATABASE-NAME & "';Connect Timeout=30")

cnnConnection.Open()
cnnConnection.Close()



Thank you,
Govind

Rohanphavde, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rohanphavde on: 1/21/2014 [Member] Starter | Points: 25

Up
0
Down
Could not open new database 'dbDummyConnect'. CREATE DATABASE is aborted.
Cannot attach the file 'D:\PoojaBackup\Connect_Folder\FOR POOJA\WebSite1\BizzApp\BizzApp\bin\Debug\Database\dbConnect.mdf' as database 'dbDummyConnect'.
File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\dbConnect_1.ldf" may be incorrect.
The log cannot be rebuilt because the database was not cleanly shut down.


Rohanphavde, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response