Issue on creating backup of database

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi All,
I am trying to backup database.
But it always throw error:
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open backup device D:/Backup1/1.bak. Operating system error 123(The filename, directory name, or volume label syntax is incorrect.).<br/>
[Microsoft][ODBC SQL Server Driver][SQL Server]BACKUP DATABASE is terminating abnormally.
Here is my code:
this.Cursor = Cursors.WaitCursor;<br/>
//create an instance of a server class<br/>
SQLDMO._SQLServer srv = new SQLDMO.SQLServer();<br/>
//connect to the server<br/>
<br/>
srv.Connect("DATAl\DATA08", "sa", "XXXXX");<br/>
//create a backup class instance<br/>
SQLDMO.Backup bak = new SQLDMO.Backup();<br/>
//set the backup device = files property ( easy way )<br/>
bak.Devices = bak.Files;<br/>
//set the files property to the File Name text boxSQLServer2005MSSQLUser$<br/>
bak.Files = @"D:/Backup1/1.bak";<br/>
//set the database to the chosen database<br/>
bak.Database = "DBName";<br/>
//perform the backup<br/>
bak.SQLBackup(srv);<br/>
MessageBox.Show("Database successfully backed up.", "Backup Successfull");<br/>
this.Cursor = Cursors.Default;

Anyone have any idea.
Thanks in advance.


View the full article
 
Back
Top