资源简介
本模块主要实现了备份数据库、还原数据库功能。在对数据库进行操作前,首先需要选择服务器,及输入相应的用户名和密码,进行登录,然后才能对数据库进行操作。单击“备份数据库”按钮,打开“备份本地数据库”窗口,如图1.2所示。输入备份文件名,选择要备份的数据库,然后再选择保存备份文件的路径,单击“确定”按钮对数据库进行备份。
代码片段和文件信息
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;
namespace SQL_Distill
{
public partial class frmAppend : Form
{
public frmAppend()
{
InitializeComponent();
}
public string strserver = ““;
public string struser = ““;
public string strpwd = ““;
private void button3_Click(object sender EventArgs e)
{
this.Close();
}
private void button1_Click(object sender EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
}
}
private void button2_Click(object sender EventArgs e)
{
if (textBox1.Text.Trim() == ““)
{
MessageBox.Show(“注意:信息不完整!“ “警告“ MessageBoxButtons.OK MessageBoxIcon.Exclamation);
}
else
{
using (SqlConnection con = new SqlConnection(“server=.;pwd=“ + strpwd + “;uid=“ + struser + “;database=master“))
{
try
{
string[] getInfo = new string[2];
string mdfpath = textBox1.Text.Trim();//mdf路径
string DataName = mdfpath.Substring(mdfpath.LastIndexOf(“\\“)+1mdfpath.Length-mdfpath.LastIndexOf(“\\“)-1);
DataName = DataName.Remove(DataName.LastIndexOf(“_“));
string logName =mdfpath.Remove(mdfpath.LastIndexOf(“\\“))+“\\“+DataName + “_log.ldf“;
SqlCommand cmd = new SqlCommand();
con.Open();
cmd.Connection = con;
StringBuilder sb = new StringBuilder();
sb.Append(“sp_attach_db @dbname=‘“ + DataName + “‘“);
sb.Append(“@filename1=‘“ + mdfpath + “‘“);
if (System.IO.File.Exists(logName))
{
sb.Append(“@filename2=‘“ + logName + “‘“);
}
else
{
MessageBox.Show(“注意:缺少必备的log文件!“ “警告“ MessageBoxButtons.OK MessageBoxIcon.Exclamation);
}
cmd.CommandText = sb.ToString();
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show(“提示:附加成功!“ “提示“ MessageBoxButtons.OK MessageBoxIcon.Exclamation);
getInfo[0] = mdfpath.Substring(mdfpath.LastIndexOf(“\\“) + 1 mdfpath.Length - mdfpath.LastIndexOf(“\\“) - 1);
getInfo[1] = mdfpath;
ListViewItem lvi =
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5632 2005-12-08 14:51 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\bin\Debug\SQL-Distill.vshost.exe
文件 3437 2008-07-29 16:59 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmAppend.cs
文件 7265 2008-07-29 15:35 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmAppend.Designer.cs
文件 6017 2008-07-29 15:35 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmAppend.resx
文件 3608 2008-08-18 10:39 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmBackup.cs
文件 7022 2008-07-29 15:34 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmBackup.Designer.cs
文件 6022 2008-07-29 15:34 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmBackup.resx
文件 6765 2008-07-31 09:16 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmDataExport.cs
文件 7564 2008-07-30 08:28 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmDataExport.Designer.cs
文件 6017 2008-07-30 08:28 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmDataExport.resx
文件 13851 2008-08-21 09:25 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmMain.cs
文件 22806 2008-08-04 13:39 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmMain.Designer.cs
文件 15513 2008-08-04 13:39 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmMain.resx
文件 7001 2008-08-04 12:59 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmOutData.cs
文件 7601 2008-07-30 14:32 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmOutData.Designer.cs
文件 6017 2008-07-30 14:32 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmOutData.resx
文件 3305 2008-07-31 08:44 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmRevert.cs
文件 6667 2008-07-29 13:20 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmRevert.Designer.cs
文件 6017 2008-07-29 13:20 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\frmRevert.resx
文件 409600 2013-03-05 09:14 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\obj\Debug\Interop.Microsoft.Office.Core.dll
文件 1273856 2013-03-05 09:14 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\obj\Debug\Interop.Microsoft.Office.Interop.Excel.dll
文件 778240 2013-03-05 09:14 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\obj\Debug\Interop.Microsoft.Office.Interop.Word.dll
文件 950272 2013-03-05 09:14 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\obj\Debug\Interop.SQLDMO.dll
文件 57344 2013-03-05 09:14 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\obj\Debug\Interop.VBIDE.dll
文件 1159 2013-03-05 09:14 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\obj\Debug\SQL-Distill.csproj.GenerateResource.Cache
文件 873 2013-03-05 09:14 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\obj\Debug\SQL-Distill.csproj.ResolveComReference.cache
文件 180 2013-03-05 09:14 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\obj\Debug\SQL_Distill.frmAppend.resources
文件 180 2013-03-05 09:14 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\obj\Debug\SQL_Distill.frmBackup.resources
文件 180 2013-03-05 09:14 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\obj\Debug\SQL_Distill.frmDataExport.resources
文件 7079 2013-03-05 09:14 SQL数据备份恢复程序\SQL-Distill\Backup\SQL-Distill\obj\Debug\SQL_Distill.frmMain.resources
............此处省略96个文件信息
相关资源
- C#如何访问firebird2.5.8嵌入式小型数据
- 旅游管理系统代码+设计文档
- 考勤系统 C#+SqlServer
- c# 固定资产源码,支持sql ,access,完
- 高校OA系统
- asp.net+sql server 开发的花店网站源码
- 工资管理系统数据库课设报告()
- c#图书管理系统C#源码和SQL数据库
- 留言板 留言板 sql c# vs 留言板 sql c#
- C#.net宠物商店管理系统带数据库完整
- Excel导入SQLServer数据库工具含源码
- C#图书管理系统含数据库、文档
- C# 数据库连接MySQL、SQL server并读取数
- C#winform导入excel到SQL Server
- ASP.NET+SQL学生二手物品交易系统(毕业
- asp.net网上商城系统原创数据库课程设
- 基于SQL SERVER 2008实现的学生学籍管理
- 酒店管理系统C#源代码编写SQL Server数
- asp.net mvc4 +sqlite
- asp.net+sql家庭财务管理系统
- pi数据库采集程序
- 图书租借管理系统(C#源码 MySQL)
- C#银行管理系统——数据库课设
- c#+sql 学生信息管理系统
- C#学生宿舍管理系统SQL版
- 学生成绩管理系统(带数据库)C#
- c#和sql2000的教材管理系统
- 学生作业管理系统asp.net+sqlserver写的
- 基于Web的学生信息管理系统的设计与
- 在线答疑系统附带毕业设计论文和p
评论
共有 条评论