Reputation: 3
Please I developed a software with VB.NET and SQL Server. The backup section works fine during development but gives errors after I deployed the software. Below are the codes are used for the backup"
Try
Cursor = Cursors.WaitCursor
Timer2.Enabled = True
If mysqlconnectionstring.State = ConnectionState.Closed Then
mysqlconnectionstring.Open()
End If
If (Not System.IO.Directory.Exists("C:\LotSMSBackup")) Then
System.IO.Directory.CreateDirectory("C:\LotSMSBackup")
End If
Dim destdir As String = "C:\LotSMSBackup\LotSMSBackup " & DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss") & ".bak"
Dim cb As String = "backup database [" & System.Windows.Forms.Application.StartupPath & "\Data" & "\Schooldb.mdf] to disk='" & destdir & "'with init,stats=10"
Dim cmd As SqlCommand = New SqlCommand(cb)
cmd.Connection = mysqlconnectionstring
cmd.ExecuteReader()
MessageBox.Show("Successfully performed", "Database Backup", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
mysqlconnectionstring.Close()
End Try
Below is the error I am getting;
The identifier that starts with ‘C:\Users\Tawiah Lot\AppData\Local\Apps\2.0\MYZD1.GJK\VN8DB86Q.X24\sms…tion_f2ac7542c8a7d9f7_0001.0000_74e25af910bfcd28\Data’ is too long. Maximum length is 128.
Upvotes: 0
Views: 52
Reputation: 3
I used click once to deploy the application which makes the application run from C:\Users\Tawiah Lot\AppData\Local\Apps\2.0\MYZD1.GJK\VN8DB86Q.X24\sms…tion_f2ac7542c8a7d9f7_0001.0000_74e25af910bfcd28\Data’ This makes the path longer thereby making the length more than the maximum of 128. In other to solve it, I user a third party software "advance installers". This creates a folder with the company name under program files. Thank you all for your support.
Upvotes: 0
Reputation: 8687
Here is your error:
"backup database [" & System.Windows.Forms.Application.StartupPath & "\Data" & "\Schooldb.mdf] to disk='" & destdir & "'with init,stats=10"
You should provide database name here, not the path
Upvotes: 1