PublicSub bk()
TryDim strDatabasePath AsString = My.Computer.FileSystem.CombinePath(My.Application.Info.DirectoryPath, "LIC.mdf")
Dim strdbLogPath AsString = My.Computer.FileSystem.CombinePath(My.Application.Info.DirectoryPath, "LIC_log.ldf")
'Dim strDatabasePath As String = My.Computer.FileSystem.CombinePath(Application.UserAppDataPath, "LIC.mdf")'Dim strdbLogPath As String = My.Computer.FileSystem.CombinePath(Application.UserAppDataPath, "LIC_log.ldf")
MsgBox(Application.UserAppDataPath)
' DB.Connection can be any valid SQLConnection which you might already be using in your applicationDim con AsNew SqlClient.SqlConnection(LIC.My.Settings.LICConnectionString)
Dim srvCon AsNew ServerConnection(con)
Dim srv As Server = New Server(srvCon)
MsgBox(srv.ToString)
If srv.Databases.Contains(strDatabasePath) Then
MsgBox("In If")
If con.State = ConnectionState.Open Then
MsgBox(con.State)
con.Close()
EndIf
MsgBox(con.State & " Is It True?")
srv.KillAllProcesses(My.Computer.FileSystem.CombinePath(My.Application.Info.DirectoryPath, "LIC.mdf"))
srv.DetachDatabase(strDatabasePath, True)
My.Computer.FileSystem.CopyFile(strDatabasePath, "c:\backup\LIC.mdf", True)
My.Computer.FileSystem.CopyFile(strdbLogPath, "c:\backup\LIC_log.ldf", True)
MessageBox.Show("Backup taken successfully")
EndIf
srvCon.Disconnect()
con.Open()
Catch ex As Exception
MessageBox.Show("Error Occured : " & ex.Message)
EndTryEndSub
</div>
I am using the given code to copy my database files...it works like a charm in debug mode but as soon as i create a setup<br/>...it stops working...the erroris <strong>"Database Detach Failed"</strong> ... i tried checking the code line by line and found that the code <br/>does not enter the IF block.. .i have no idea why...can i get some help on this??<br/>
Ummmm...actually i am making a windows form applicaton...i know this is not the right place to post this question...but i have been trying to solve this issue since ages..so....
bronxbull
Member
237 Points
255 Posts
code stops working after i create a setup using publish wizard
Jan 15, 2012 02:01 PM|LINK
Yousef_Jadal...
Star
8822 Points
1502 Posts
Re: code stops working after i create a setup using publish wizard
Jan 15, 2012 02:08 PM|LINK
This line of code will make problems when you publish your web site :
bronxbull
Member
237 Points
255 Posts
Re: code stops working after i create a setup using publish wizard
Jan 15, 2012 02:12 PM|LINK
Ummmm...actually i am making a windows form applicaton...i know this is not the right place to post this question...but i have been trying to solve this issue since ages..so....
Yousef_Jadal...
Star
8822 Points
1502 Posts
Re: code stops working after i create a setup using publish wizard
Jan 15, 2012 02:19 PM|LINK
You are welcome dude.
Then you can post your problem here : http://social.msdn.microsoft.com/Forums/en-US/categories
kattyjems
Member
120 Points
50 Posts
Re: code stops working after i create a setup using publish wizard
Mar 05, 2012 10:48 AM|LINK
Hi,
It's highly dangorous to use Message.Shoe function.
You can use ScriptManager for this