<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    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.Data.SqlClient;
    using System.Data.OleDb;

    namespace CSL.Nouka.Library.Presentation
    {
        
    //-------------------------------------------------------------------------
        /// <summary>
        
    /// FrmKihonSetting
        
    /// </summary>
        //-------------------------------------------------------------------------
        public partial class FrmKihonSetting : Form
        {
            
    private string connStr = "";
            
    private OleDbConnection mySqlConnection; 

            
    //-------------------------------------------------------------------------
            /// <summary>
            
    /// init FrmKihonSetting
            
    /// </summary>
            //-------------------------------------------------------------------------
            public FrmKihonSetting()
            {
                InitializeComponent();

                
    this.txtServerName.Text = CSL.Nouka.Library.Properties.Settings.Default.DBSettingServerName;
                
    this.cmbCertification.SelectedIndex = Convert.ToInt32(CSL.Nouka.Library.Properties.Settings.Default.DBSettingCmbCertificationSelectedIndex);
                
    this.txtUserName.Text   = CSL.Nouka.Library.Properties.Settings.Default.DBSettingTxtUserName;
                
    this.txtPswd.Text       = CSL.Nouka.Library.Properties.Settings.Default.DBSettingTxtPswd;
            }

            
    //-------------------------------------------------------------------------
            /// <summary>
            
    /// Windows    認証 ----- 0
            
    /// SQL Server 認証 ----- 1
            
    /// </summary>
            
    /// <param name="sender"></param>
            
    /// <param name="e"></param>
            //-------------------------------------------------------------------------
            private void cmbCertification_SelectedIndexChanged(object sender, EventArgs e)
            {
                
    if (cmbCertification.SelectedIndex.ToString() == "0")
                {
                    
    this.labelUserName.Enabled = false;
                    
    this.labelPswd.Enabled     = false;
                    
    this.txtUserName.Enabled   = false;
                    
    this.txtPswd.Enabled       = false;
                }
                
    else if (cmbCertification.SelectedIndex.ToString() == "1")
                {
                    
    this.labelUserName.Enabled = true;
                    
    this.labelPswd.Enabled     = true;
                    
    this.txtUserName.Enabled   = true;
                    
    this.txtPswd.Enabled       = true;
                }
            }

            
    //-------------------------------------------------------------------------
            /// <summary>
            
    /// OK
            
    /// </summary>
            
    /// <param name="sender"></param>
            
    /// <param name="e"></param>
            //-------------------------------------------------------------------------
            private void btnOK_Click(object sender, EventArgs e)
            {
                
    if (cmbCertification.SelectedIndex.ToString() == "0")
                {
                    connStr 
    = "Provider=SQLOLEDB;Server=" + this.txtServerName.Text + ";Trusted_Connection=Yes;Database=Nouka";
                }
                
    else
                {
                    connStr 
    = "Provider=SQLOLEDB;Server=" + this.txtServerName.Text + ";uid=" + this.txtUserName.Text + ";pwd=" + this.txtPswd.Text + ";Database=Nouka";
                    CSL.Nouka.Library.Properties.Settings.Default.DBSettingTxtUserName 
    = this.txtUserName.Text;
                    CSL.Nouka.Library.Properties.Settings.Default.DBSettingTxtPswd 
    = this.txtPswd.Text;
                }
                CSL.Nouka.Library.Properties.Settings.Default.ConnStr 
    = connStr;
                CSL.Nouka.Library.Properties.Settings.Default.DBSettingCmbCertificationSelectedIndex 
    = cmbCertification.SelectedIndex.ToString();
                CSL.Nouka.Library.Properties.Settings.Default.DBSettingServerName 
    = this.txtServerName.Text;
                
    if (isConnectSucceed(connStr))
                {
                    CSL.Nouka.Library.Properties.Settings.Default.Save();
                    MessageBox.Show(
    "データベースに接続しました。""接続", MessageBoxButtons.OK);
                    
    this.Close();
                }
                
    else
                {
                    MessageBox.Show(
    "接続失敗しました。""接続", MessageBoxButtons.OK);
                }
            }

            
    //-------------------------------------------------------------------------
            /// <summary>
            
    /// Cancel
            
    /// </summary>
            
    /// <param name="sender"></param>
            
    /// <param name="e"></param>
            //-------------------------------------------------------------------------
            private void btnCancel_Click(object sender, EventArgs e)
            {
                
    this.Close();
            }

            
    //-------------------------------------------------------------------------
            /// <summary>
            
    /// Test Connection
            
    /// </summary>
            
    /// <param name="connStr"></param>
            
    /// <returns></returns>
            //-------------------------------------------------------------------------
            private bool isConnectSucceed(string connStr)
            {
                
    bool isSucceed = false;
                
    try
                {
                    mySqlConnection 
    = new OleDbConnection(connStr);
                    mySqlConnection.Open();
                    isSucceed 
    = true;
                }
                
    catch
                {
                    isSucceed 
    = false;
                }
                
    finally
                {
                    mySqlConnection.Close();
                }
                
    return isSucceed;
            }
        }
    }








    posted on 2010-11-24 16:13 Ying-er 閱讀(268) 評論(0)  編輯  收藏 所屬分類: .Net
    主站蜘蛛池模板: 中文字幕无码一区二区免费| 国产精品无码免费专区午夜| 亚洲另类古典武侠| 亚洲www77777| 精品久久久久亚洲| 十八禁视频在线观看免费无码无遮挡骂过 | 亚洲中文字幕无码中文字| 香蕉视频在线观看免费| 久热免费在线视频| 国产高清视频在线免费观看| 免费人成视频在线| 怡红院亚洲怡红院首页| 亚洲国产一区在线| 亚洲精品动漫免费二区| 免费人成在线观看网站品爱网 | 久久久久久久99精品免费| 国产一区二区三区免费视频| 内射少妇36P亚洲区| 久久久久久久久久免免费精品| 手机看黄av免费网址| 国产亚洲精AA在线观看SEE| 亚洲av无码日韩av无码网站冲| 香港a毛片免费观看| 久久精品国产亚洲AV电影| 91精品免费国产高清在线| 亚洲女久久久噜噜噜熟女| 精品国产亚洲一区二区三区在线观看| 最好免费观看韩国+日本| 色婷婷六月亚洲婷婷丁香| 中文字幕人成无码免费视频| 亚洲高清不卡视频| 你懂得的在线观看免费视频| 亚洲日本韩国在线| 黄网站色视频免费看无下截| 亚洲中文字幕成人在线| 久久久精品免费视频| 亚洲不卡中文字幕| 2021国内精品久久久久精免费| 亚洲福利视频导航| 免费成人在线视频观看| 亚洲Av无码专区国产乱码DVD|