Private void Backup (string strFileName)
{
try
{
string command=@"BACKUP DATABASE Pubs TO DISK='" + strFileName + " ' ";
this.Cursor= Cursors.WaitCursor;
SqlCommand oCommand=null;
SqlConnection oConnection = null;
oConnection=new SqlConnection ( "Data Source=.; Initial Catalog=Pubs;
Integrated Security=True");
if (oConnection.State !=ConnectionState.Open)
oConnection.Open();
oCommand =new SqlCommand ( Sqlcommand, oConnection);
oCommand.ExecuteNonQuery();
this.cursor=Cursors.Default;
MessageBox.show(" تهيه نسخه پشتيبان از اطلاعات با موفقيت انجام شد.");
}
Catch (Exception ex)
{
MessageBox.Show ("Error Occurd : " + ex.Message);
}
}
من اين كد رو استفاده كردم اين قسمت كه زيرش خط كشيدم ومروبش كردم
ميزنهsql داخل پرانتز موجود نيست