资源简介
C#将SQL Server备份bak文件恢复

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Diagnostics;
namespace resume
{
public partial class ComeBack : Form
{
public ComeBack()
{
InitializeComponent();
}
private void btnRevertPath_Click(object sender EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = Application.StartupPath + “\\“;
ofd.Filter = “备份文件(*.bak)|*.bak“;
if (ofd.ShowDialog() == DialogResult.OK)
{
this.txtRevertPath.Text = ofd.FileName;
this.btnRevert.Enabled = true;
}
}
private void btnRevert_Click(object sender EventArgs e)
{
string connStr = “Data Source=.\\SQLEXPRESS;Initial Catalog=Master;user id=sa;Pwd=123“;
SqlConnection con = new SqlConnection(connStr);
try
{
con.Open();
string sql = ““;
sql = “use Master“;
SqlCommand com = new SqlCommand(sql con);
com.ExecuteNonQuery();
sql = “drop database GPRS“;
com = new SqlCommand(sql con);
com.ExecuteNonQuery();
sql = string.Format(“use master restore database {0} from disk = ‘{1}‘“ “GPRS“ txtRevertPath.Text);
com = new SqlCommand(sql con);
com.ExecuteNonQuery();
DialogResult result = MessageBox.Show(“数据库恢复成功!“ “提示“ MessageBoxButtons.OK MessageBoxIcon.Information);
if (result == DialogResult.Yes)
{
Process.Start(Application.StartupPath + “\\Hotel.exe“);
Application.Exit();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
}
}
private void grbRevert_Enter(object sender EventArgs e)
{
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 20480 2010-06-27 16:23 resume\resume\bin\Debug\resume.exe
文件 44544 2010-06-27 16:23 resume\resume\bin\Debug\resume.pdb
文件 5632 2005-11-11 22:25 resume\resume\bin\Debug\resume.vshost.exe
..A.SH. 9 2010-04-21 19:51 resume\resume\bin\Debug\_desktop.ini
..A.SH. 9 2010-04-21 19:51 resume\resume\bin\_desktop.ini
文件 2357 2010-06-27 16:23 resume\resume\ComeBack.cs
文件 4767 2010-06-27 16:07 resume\resume\ComeBack.Designer.cs
文件 5814 2010-06-27 16:07 resume\resume\ComeBack.resx
..A.SH. 9 2010-04-21 19:51 resume\resume\obj\Debug\Refactor\_desktop.ini
文件 180 2010-06-27 16:07 resume\resume\obj\Debug\resume.ComeBack.resources
文件 845 2010-06-27 16:07 resume\resume\obj\Debug\resume.csproj.GenerateResource.Cache
文件 20480 2010-06-27 16:23 resume\resume\obj\Debug\resume.exe
文件 44544 2010-06-27 16:23 resume\resume\obj\Debug\resume.pdb
文件 180 2008-10-15 20:20 resume\resume\obj\Debug\resume.Properties.Resources.resources
..A.SH. 9 2010-04-21 19:51 resume\resume\obj\Debug\TempPE\_desktop.ini
..A.SH. 9 2010-04-21 19:51 resume\resume\obj\Debug\_desktop.ini
文件 264 2010-06-27 16:25 resume\resume\obj\resume.csproj.FileList.txt
文件 688 2010-01-21 16:49 resume\resume\obj\resume.csproj.FileListAbsolute.txt
..A.SH. 9 2010-04-21 19:51 resume\resume\obj\_desktop.ini
文件 468 2008-10-15 20:19 resume\resume\Program.cs
文件 1184 2008-10-15 20:18 resume\resume\Properties\AssemblyInfo.cs
文件 2866 2008-10-15 20:18 resume\resume\Properties\Resources.Designer.cs
文件 5612 2008-10-15 20:18 resume\resume\Properties\Resources.resx
文件 1089 2008-10-15 20:18 resume\resume\Properties\Settings.Designer.cs
文件 249 2008-10-15 20:18 resume\resume\Properties\Settings.settings
..A.SH. 9 2010-04-21 19:51 resume\resume\Properties\_desktop.ini
文件 3234 2008-10-15 20:20 resume\resume\resume.csproj
..A.SH. 9 2010-04-21 19:51 resume\resume\_desktop.ini
文件 907 2008-10-15 20:18 resume\resume.sln
..A..H. 14336 2010-06-27 17:42 resume\resume.suo
............此处省略13个文件信息
- 上一篇:用c#写的多线程求PI
- 下一篇:利用C#语言开发K-Means聚类算法
相关资源
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
评论
共有 条评论