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();