0
backup sql with c#
سلام
خسته نباشید
میخواستم بتونم با برنامه ام که با windows application c# نوشته شده بتونم از sql server نسخه پشتیبان تهیه کنم
SqlCommand ocommand = new SqlCommand(); SqlConnection oconnection = new SqlConnection(); ; oconnection = new SqlConnection("server=.;database= madanchian; Integrated Security = True"); ocommand.Connection = oconnection; if (oconnection.State != ConnectionState.Open) oconnection.Open(); string db = ocommand.Connection.Database; oconnection.Close(); SqlConnection.ClearAllPools(); string command = @"BACKUP DATABASE [F:\H\DB\MadanChian.mdf] To Disk='" + filename + "' WITH NOINIT , STATS = 10"; ocommand.Connection = new SqlConnection("server=.; Integrated Security = True"); ocommand.CommandText = command; ocommand.Connection = oconnection; oconnection.Open(); ocommand.ExecuteNonQuery(); oconnection.Close();
ولی با این کد نتونستم.
پیغام زیر نشون داده میشه
آدرس مبدا و مقصد دیتا بیس هم درسته
خود دیتا بیس هم سالمه و کار هم میکنه
با این حال بازم نتونستم موفق بشم
1 پاسخ
0
سلام به شما دوست عزیز
به جای این که آدرس فایل mdf دیتابیس رو وارد کنید نام دیتابیس رو در کوئری backup وارد کنید.