打包数据库 下载本文

else {

// 添加连接字符串节点

configuration.ConnectionStrings.ConnectionStrings.Add( new ConnectionStringSettings( \

GetConnectionString(), \ }

// 保存配置

configuration.SaveAs(

string.Format(@\\

ConfigurationSaveMode.Minimal);

// 关闭窗体 this.Close(); }

catch (Exception ex) {

MessageBox.Show(

string.Format(\保存数据库连接配置时发生以下错误:\\r\\n\\r\\n{0}\e),

this.Text,

MessageBoxButtons.OK, MessageBoxIcon.Error); } }

///

/// [取消]按钮点击事件 ///

///

private void btnCancel_Click(object sender, EventArgs e) {

this.Close(); }

///

/// [浏览]按钮点击事件 ///

///

private void btnBrowse_Click(object sender, EventArgs e) {

OpenFileDialog ofDlg = new OpenFileDialog(); ofDlg.Title = \选择 SQL Server 数据库文件\

ofDlg.Filter = \数据库(*.mdf)|*.mdf|所有文件(*.*)|*.*\ ofDlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

DialogResult result = ofDlg.ShowDialog(this); if (result == DialogResult.OK)

txtDataBaseFilePath.Text = ofDlg.FileName; }

///

/// [获取连接字符串]按钮点击事件 ///

///

private void btnGetConnectionString_Click(object sender, EventArgs e) {

this.txtConnectionString.Text = GetConnectionString(); }

#endregion } }

设计器源码:

namespace CodingMouse.CMCSharpSDK.UI.Forms {

partial class frmConnectionConfig {

///

/// 必需的设计器变量。 ///

private System.ComponentModel.IContainer components = null;

///

/// 清理所有正在使用的资源。 ///

///

protected override void Dispose(bool disposing) {

if (disposing && (components != null))

{

components.Dispose(); }

base.Dispose(disposing); }

#region Windows 窗体设计器生成的代码

///

/// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 ///

private void InitializeComponent() {

this.components = new System.ComponentModel.Container(); this.cboSqlDataSource = new System.Windows.Forms.ComboBox(); this.tcServerInfo = new System.Windows.Forms.TabControl(); this.tpConnectionInfo = new System.Windows.Forms.TabPage();

this.gbConnectToADataBase = new System.Windows.Forms.GroupBox(); this.txtLogicalName = new System.Windows.Forms.TextBox(); this.lblLogicalName = new System.Windows.Forms.Label(); this.btnBrowse = new System.Windows.Forms.Button();

this.cboDataBaseName = new System.Windows.Forms.ComboBox(); this.txtDataBaseFilePath = new System.Windows.Forms.TextBox(); this.rdoAttachADataBaseFile = new System.Windows.Forms.RadioButton();

this.rdoSelectOrEnterADataBaseName = new System.Windows.Forms.RadioButton();

this.gbLogOnToTheServer = new System.Windows.Forms.GroupBox(); this.txtPassword = new System.Windows.Forms.TextBox();