This is the query in which i m getting error
CreateTableCommand.CommandText = "BACKUP DATABASE Test" +
"TO DISK = 'C:\backup\t1.bak'" +
"WITH " +
"NOFORMAT, " +
"COMPRESSION," +
"NOINIT, " +
"NAME = N't1-Full Database Backup'," +
"SKIP, " +
"STATS = 10;";
and the error is “Incorrect syntax near ‘DISK’.”
but if i run run that query ms sql server 2008 its work fine but when i try to use that in my C# application it gave error pls help me out
Add another space after
Test, your SQL is built to... TestTO DISK ....As Onots pointed out, you should also escape some characters properly (
\introduces an escape sequence,\itself is escaped as\\):See also MSDN: string (C# Reference) for details.