zoukankan      html  css  js  c++  java
  • 操作MSSQL服务还有测试是否连接

           private void btnOk_Click(object sender, EventArgs e)
            {
                IList<string> _DataBaseList = new List<string>();
                System.ServiceProcess.ServiceController sc = new System.ServiceProcess.ServiceController();
                sc.ServiceName = "MSSQLSERVER";
                if (sc == null)
                {
                    MessageBox.Show("您的机器上没有安装SQL SERVER!", "提示信息");
                    return;
                }
                else if (sc.Status != System.ServiceProcess.ServiceControllerStatus.Running)
                {
                    MessageBox.Show("SQL数据库服务未启动,请点击开启SQL服务!", "提示信息");
                    return;
                }
                //_DBConfig = new DBConfig();
                if (cboServerName.Text == "Local(本机)")
                {
                    _DBConfig.ServerName = "(local)";
                }
                else
                {
                    _DBConfig.ServerName = cboServerName.Text.ToString();
                }
                if (cboValidataType.Text == "Windows身份认证")
                {
                    _DBConfig.ValidataType = "Windows身份认证";
                }
                else
                {
                    txtPassword.Enabled = true;
                    txtUser.Enabled = true;
                    _DBConfig.ValidataType = "SQL Server身份认证";
                    _DBConfig.UserName = txtUser.Text.ToString();
                    _DBConfig.UserPwd = txtPassword.Text.ToString();

                }
                _conString = GetSQLmasterConstring(_DBConfig);
                _DBConfig.DB = new DBUtility.DbHelperSQL(_conString);
                _DataBaseList = _DBConfig.DB.GetDataBaseInfo();
                if (_DataBaseList.Count > 0)
                {
                    cboDataBase.DataSource = _DataBaseList;
                    cboDataBase.Enabled = true;
                    cboDataBase.SelectedIndex = 0;
                }
                else
                {
                    cboDataBase.Enabled = false;
                    cboDataBase.Text = "";
                    cboDataBase.DataSource = null;
                }

  • 相关阅读:
    TFS应用层服务器获取F5用户的真实IP地址(高可用性)
    安装TFS(2015)工作组模式代理服务器(Agent)
    Team Foundation Server 15 功能初探
    TFS 2013 生成(构建)历史记录保持策略(Retention Policy)
    TFS代码变更和工作项关联,为系统变更提供完美的跟踪轨迹
    修改TFS客户端的工作区类型
    比较TFS与SVN,你必须知道的10点区别
    数据字典
    查看源码 类图结构图(Eclipse + Idea)
    Mybatis对应的java和数据库的数据类型
  • 原文地址:https://www.cnblogs.com/wujy/p/2510824.html
Copyright © 2011-2022 走看看