+2 امتیاز
[no viewer found for format: markdown]

6 پاسخ

0 امتیاز

با عرض پوزش

در کد backup و Restore که براتون گذاشتم از یک کلاس استفاده کرده بودم که تمامی کدهای sql رو پوشش میده

با استفاده از این کلاس کد backup و Restore هم کار میکنه

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;


static class Class1
    {

    public static void SetData(string str)
        {
            SqlConnection mconnection = new SqlConnection(// Address ConnectionString);
            SqlCommand command = new SqlCommand(str, mconnection);
            command.CommandType = CommandType.Text;
            command.CommandText = str;
            mconnection.Open();
            try
            {
                command.ExecuteNonQuery();
            }
            catch (SqlException myerror)
            {
                MessageBox.Show("Error Connecting to Database: " + myerror.Message);

            }
            finally
            {
                mconnection.Close();
                mconnection.Dispose();
            }
        }
     public static DataTable GetData(string str)
        {
            SqlConnection nconnection = new SqlConnection(connectionString);
            SqlCommand command = new SqlCommand(str, nconnection);
            SqlDataAdapter adapter = new SqlDataAdapter();
            adapter.SelectCommand = command;
             DataTable dt = new DataTable();

            try
            {
                adapter.Fill(dt);
            }
            catch (SqlException myerror)
            {
                MessageBox.Show("Error Connecting to Database: " + myerror.Message);
            }
            finally
            {
                nconnection.Dispose();
            }
            return dt;
        }
     }
     


 

0 امتیاز
من گیج شدم یه کد خواستما
توسط (222 امتیاز) 4 28 49
0 امتیاز

سلام 

 

از اين كد استفاده كن كد بك آپ و ريستور با همه فقط بايد مسير كانكشن رو تغيير بدي و به راحتي بك آپ بگيري .

 

http://s5.picofile.com/file/8140508068/backup_restore_100_.txt.html

 

سوال جدید

2,337 سوال

2,871 پاسخ

3,725 دیدگاه

3,925 کاربر

دسته بندی ها

...