91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡(jiǎn)介

用C#寫的實(shí)現(xiàn)數(shù)據(jù)庫備份與還原的工程(VS2008下可直接運(yùn)行,低于08的版本可以拷貝代碼實(shí)現(xiàn),記得要在COM中添加SQLSMO引用,本例數(shù)據(jù)庫為SuperMarket,請(qǐng)更改為你所需備份的數(shù)據(jù)庫),個(gè)人特意將兩種方法放在同一工程內(nèi),F(xiàn)orm1是直接用SQL語句實(shí)現(xiàn)的,F(xiàn)orm2是使用SQLSMO實(shí)現(xiàn)的,還有進(jìn)度條控制,界面也挺漂亮的,因?yàn)闉榱藗€(gè)人存檔。

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.IO;//File
using?System.Data.SqlClient;
using?System.Collections;//ArrayList

namespace?BFHY
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}

????????public?void?beifenInfo()
????????{
????????????try
????????????{
????????????????saveFileDialog1.InitialDirectory?=?Application.StartupPath?+?“\\“;//默認(rèn)路徑為D://
????????????????saveFileDialog1.FilterIndex?=?1; //默認(rèn)值為第一個(gè)
????????????????saveFileDialog1.RestoreDirectory?=?true; //重新定位保存路徑
????????????????saveFileDialog1.Filter?=?“備份文件?(*.bak)|*.bak|所有文件?(*.*)|*.*“;//篩選器,定義文件類型
????????????????if?(saveFileDialog1.ShowDialog()?==?DialogResult.OK)
????????????????{
????????????????????if?(!File.Exists(saveFileDialog1.FileName.ToString()))
????????????????????{
????????????????????????SqlConnection?Con?=?new?SqlConnection(“Data?Source=.;Initial?Catalog=master;User?ID=sa;pwd?=xx“);
????????????????????????Con.Open();//k
????????????????????????SqlCommand?com?=?new?SqlCommand(“BACKUP?DATAbase??SuperMarket?TO?DISK?=?‘“?+?saveFileDialog1.FileName.ToString()?+?“‘“?Con);
????????????????????????this.textBox1.Text?=?saveFileDialog1.FileName.ToString();
????????????????????????com.ExecuteNonQuery();
????????????????????????Con.Close();//g??????????????????????
????????????????????????MessageBox.Show(“數(shù)據(jù)備份成功!“);
????????????????????}
????????????????????else
????????????????????{
????????????????????????MessageBox.Show(“請(qǐng)重新命名!“);
????????????????????}
????????????????}
????????????}
????????????catch?(Exception?k)
????????????{
????????????????MessageBox.Show(k.Message);
????????????????return;
????????????}
????????}

????????public?static?void?Restore(string?path)
????????{
????????????//殺死原來所有的數(shù)據(jù)庫連接進(jìn)程
????????????SqlConnection?con?=?new?SqlConnection(“Data?Source=.;Initial?Catalog=master;User?ID=sa;pwd?=xx“);
????????????con.Open();//k
????????????SqlCommand?cmd?=?new?SqlCommand(“SELECT?spid?FROM?sysprocesses?sysdatabases?WHERE?sysprocesses.dbid=sysdatabases.dbid?AND?sysdatabases.Name=‘SuperMarket‘“?con);
????????????SqlDataReader?dr;
????????????ArrayList?list?=?new?ArrayList();
????????????try
????????????{
????????????????dr?=?cmd.ExecuteReader();
????????????????while?(dr.Read())
????????????????{
????????????????????list.Add(dr.GetInt16(0));
????????????????}
????????????????dr.Close();
????????????}
????????????catch?(SqlException?ex)
????????????{
????????????????MessageBox.Show(ex.ToString());
????????????}
????????????finally
????????????{
????????????????con.Close();//g
????????????}
????????????con.Open();//k
????????????for?(int?i?=?0;?i?????????????{
????????????????cmd?=?new?SqlCommand(string.Format(“KILL?{0}“?list[i]

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件???????4676??2009-05-09?16:20??BFHY\BFHY\BFHY.csproj

?????文件??????14328??2009-05-09?16:16??BFHY\BFHY\bin\Debug\BFHY.vshost.exe

?????文件????????490??2007-07-21?01:33??BFHY\BFHY\bin\Debug\BFHY.vshost.exe.manifest

?????文件???????4831??2009-05-09?16:17??BFHY\BFHY\Form1.cs

?????文件???????5582??2009-05-09?16:17??BFHY\BFHY\Form1.Designer.cs

?????文件?????253253??2009-05-09?16:17??BFHY\BFHY\Form1.resx

?????文件???????4896??2009-05-09?16:20??BFHY\BFHY\Form2.cs

?????文件??????10406??2009-05-09?16:20??BFHY\BFHY\Form2.Designer.cs

?????文件?????253253??2009-05-09?16:20??BFHY\BFHY\Form2.resx

?????文件????????187??2009-05-09?16:16??BFHY\BFHY\obj\Debug\BFHY.csproj.FileListAbsolute.txt

?????文件????????579??2009-05-09?16:02??BFHY\BFHY\obj\Debug\BFHY.csproj.ResolveComReference.cache

?????文件?????950272??2009-05-09?16:02??BFHY\BFHY\obj\Debug\Interop.SQLDMO.dll

?????文件???????5120??2009-05-09?16:20??BFHY\BFHY\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll

?????文件????????485??2009-05-09?15:41??BFHY\BFHY\Program.cs

?????文件???????1364??2009-05-09?15:41??BFHY\BFHY\Properties\AssemblyInfo.cs

?????文件???????3818??2009-05-09?16:20??BFHY\BFHY\Properties\Resources.Designer.cs

?????文件???????6907??2009-05-09?16:20??BFHY\BFHY\Properties\Resources.resx

?????文件???????1089??2009-05-09?15:41??BFHY\BFHY\Properties\Settings.Designer.cs

?????文件????????249??2009-05-09?15:41??BFHY\BFHY\Properties\Settings.settings

?????文件???????6038??2009-05-09?16:19??BFHY\BFHY\Resources\bf.bmp

?????文件??????17478??2009-05-09?16:18??BFHY\BFHY\Resources\hh.bmp

?????文件???????6310??2009-05-09?16:20??BFHY\BFHY\Resources\hy.bmp

?????文件????3932214??2009-05-09?16:17??BFHY\BFHY\Resources\Wallpaper.bmp

?????文件????????902??2009-05-09?15:41??BFHY\BFHY.sln

????..A..H.?????15872??2009-05-09?16:21??BFHY\BFHY.suo

?????目錄??????????0??2009-05-09?16:20??BFHY\BFHY\obj\Debug\TempPE

?????目錄??????????0??2009-05-09?15:41??BFHY\BFHY\bin\Debug

?????目錄??????????0??2009-05-09?16:16??BFHY\BFHY\obj\Debug

?????目錄??????????0??2009-05-09?15:41??BFHY\BFHY\bin

?????目錄??????????0??2009-05-09?15:41??BFHY\BFHY\obj

............此處省略7個(gè)文件信息

評(píng)論

共有 條評(píng)論