hi all.
I'm trying to back up a database in vs2008 using a stored procedure...
That creates the dump device for the backup but when i want to back up that database i want to be able to let the user choose the name of the backup
i get the strCompanyName from user input.
it gives me a syntax error
[HTML]An unhandled exception of type 'System.Data.Sq lClient.SqlExce ption' occurred in System.Data.dll
Additional information: Incorrect syntax near 'test'.[/HTML]
but when i do the command without user input
then it works 100%
Can anyone help
I'm trying to back up a database in vs2008 using a stored procedure...
Code:
Dim sqlComAddumpDevice As SqlCommand = New SqlCommand("use master exec sp_addumpdevice 'disk','CompanyBackup','C:\Backup\companyName.bak'", sqlcon)
Code:
Dim sqlComBackupDatabase As SqlCommand = New SqlCommand("Backup database ' " & strCompanyName & " ' to CompanyBackup", sqlcon)
it gives me a syntax error
[HTML]An unhandled exception of type 'System.Data.Sq lClient.SqlExce ption' occurred in System.Data.dll
Additional information: Incorrect syntax near 'test'.[/HTML]
but when i do the command without user input
Code:
Dim sqlComBackupDatabase As SqlCommand = New SqlCommand("Backup database test to CompanyBackup", sqlcon)
Can anyone help
Comment