Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to execute one query that is:

C#
string query= " RESTORE DATABASE alaki125 FROM DISK ='" + path + "' with move 'alaki' to '" + destination + "'MOVE'alaki_log' to '" + destinationlog + "'";



But this exception occured:Incorrect syntax near MOVE

I very tired pleaze help me and sending for me correct format of this string.
thanks a lot
Posted
Updated 22-Sep-11 1:34am
v2

There is no space and coma between MOVE keyword and log name.
Replace with this one

C#
string query= " RESTORE DATABASE alaki125 FROM DISK ='" + path + "' with move 'alaki' to '" + destination + "', MOVE 'alaki_log' to '" + destinationlog + "'";


For correct syntax click here.
 
Share this answer
 
C#
string query = string.Format(" RESTORE DATABASE alaki125 FROM DISK ='{0}' with move 'alaki' to '{1}', MOVE 'alaki_log' to '{2}'", path, destination, destinationlog);
 
Share this answer
 
If you view the contents of your query variable in debug you will spot the incorrect quotes and spaces in seconds.
 
Share this answer
 
string query= " RESTORE DATABASE alaki125 FROM DISK ='" + path + "' with move 'alaki' to '" + destination + "' MOVE 'alaki_log' to '" + destinationlog + "'";


Correct format of the string sent!

Major Tom checking out!

Cheers :)
 
Share this answer
 
Comments
Mario Majčica 22-Sep-11 8:39am    
Viva the sense for the humor!
Reiss 22-Sep-11 10:03am    
have my +5 to counter the 'tard
You need a comma and spaces :

C#
string query= " RESTORE DATABASE alaki125 FROM DISK ='" + path + "' with move 'alaki' to '" + destination + "', MOVE 'alaki_log' to '" + destinationlog + "'";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900