المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : can not copy database files



C# Programming
08-21-2009, 10:25 PM
hi.i want copy database files.when i do detach database throw exeption.i search web and find things.but i cant drive result.
please help me.thanks.

string ConnStr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\mydb.mdf"
+";Integrated Security=True;User Instance=True";
SqlConnection mycon = new SqlConnection(ConnStr);
SqlCommand mycom = new SqlCommand("sp_detach_db @d=db_name()", mycon);
mycon.Open();
mycom.ExecuteScalar();
mycon.Close();