Ejemplo n.º 1
0
        public void sFillListAvailableSQLServers()
        {
            //DataTable a = default(DataTable);
            //DataRow vRow = default(DataRow);
            //SmoApplication oSQLApp = default(SmoApplication);
            //oSQLApp = new SmoApplication();
            //a = oSQLApp.EnumAvailableSqlServers;
            //foreach ( vRow  in a.Rows) {
            //    TXT_ServerName.Items.Add(vRow(0));
            //}

            System.Data.Sql.SqlDataSourceEnumerator instance =
                System.Data.Sql.SqlDataSourceEnumerator.Instance;
            System.Data.DataTable dataTable = instance.GetDataSources();
            string myServer = Environment.MachineName;

            //DataTable servers = SqlDataSourceEnumerator.Instance.GetDataSources();
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                if (myServer == dataTable.Rows[i]["ServerName"].ToString()) ///// used to get the servers in the local machine////
                {
                    if ((dataTable.Rows[i]["InstanceName"] as string) != null)
                    {
                        TXT_ServerName.Items.Add(dataTable.Rows[i]["ServerName"] + "\\" + dataTable.Rows[i]["InstanceName"]);
                    }
                    else
                    {
                        TXT_ServerName.Items.Add(dataTable.Rows[i]["ServerName"]);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        ///<summary>SQLServerInstance</summary>
        public static DataTable SQLServerInstance()
        {
            System.Data.Sql.SqlDataSourceEnumerator instance =
                System.Data.Sql.SqlDataSourceEnumerator.Instance;
            System.Data.DataTable dataTable = instance.GetDataSources();

            /*
             #if (DEBUG)
             * foreach( DataRow dataRow in dataTable.Rows )
             * {
             * foreach (System.Data.DataColumn dataColumn in dataTable.Columns)
             * {
             * System.Console.WriteLine("{0} = {1}", dataColumn.ColumnName, dataRow[dataColumn]);
             * }
             * }
             #endif
             */

            return(dataTable);
        }
Ejemplo n.º 3
0
 public DataTable GetServerName()
 {
     System.Data.Sql.SqlDataSourceEnumerator instance = System.Data.Sql.SqlDataSourceEnumerator.Instance;
     System.Data.DataTable table = instance.GetDataSources();
     return(table);
 }
Ejemplo n.º 4
0
 private void Form1_Load(object sender, EventArgs e)
 {
     System.Data.Sql.SqlDataSourceEnumerator instance = System.Data.Sql.SqlDataSourceEnumerator.Instance;
     System.Data.DataTable dataTable = instance.GetDataSources();
     int count = dataTable.Rows.Count;
 }