How can I have a list of all sql servers avaiable on our LAN populated in a
DropDownList exacly like what we have when we want to specify Datasource in
ADO.Net or wherever?
Thanks 6 2828
Hello,
Easiest thing to do IMHO is to make a ref to the SQLDMO.dll and call the
method that follows :
SQLDMO.Applicat ion app = new SQLDMO.Applicat ionClass();
SQLDMO.NameList lst = app.ListAvailab leSQLServers();
IEnumerator ie = lst.GetEnumerat or();
while (ie.MoveNext())
{
Debug.WriteLine (ie.Current.ToS tring());
}
HTH,
Alex
"Reza Alirezaei" <an*******@disc ussions.microso ft.com> wrote in message
news:ut******** ******@TK2MSFTN GP09.phx.gbl... How can I have a list of all sql servers avaiable on our LAN populated in
a DropDownList exacly like what we have when we want to specify Datasource
in ADO.Net or wherever?
Thanks
that works fine,,,how can I get a list of databases available on the
specified server on a separate Combobox?
"Trebek" <al********@int heformofaquesti on.com> wrote in message
news:40******** *************** @nnrp.fuse.net. .. Hello,
Easiest thing to do IMHO is to make a ref to the SQLDMO.dll and call the method that follows :
SQLDMO.Applicat ion app = new SQLDMO.Applicat ionClass();
SQLDMO.NameList lst = app.ListAvailab leSQLServers();
IEnumerator ie = lst.GetEnumerat or();
while (ie.MoveNext())
{
Debug.WriteLine (ie.Current.ToS tring());
}
HTH, Alex
"Reza Alirezaei" <an*******@disc ussions.microso ft.com> wrote in message news:ut******** ******@TK2MSFTN GP09.phx.gbl... How can I have a list of all sql servers avaiable on our LAN populated
in a DropDownList exacly like what we have when we want to specify Datasource in ADO.Net or wherever?
Thanks
it returns a collection called a NameList, just use foreach.
private SQLDMO.NameList sqlServers;
sqlDMOApp = new SQLDMO.Applicat ion();
sqlServers = sqlDMOApp.ListA vailableSQLServ ers();
foreach (string server in sqlServers)
{
comboBox1.Items .Add(server);
}
"Reza Alirezaei" <an*******@disc ussions.microso ft.com> wrote in message
news:eH******** ******@TK2MSFTN GP09.phx.gbl... that works fine,,,how can I get a list of databases available on the specified server on a separate Combobox?
"Trebek" <al********@int heformofaquesti on.com> wrote in message news:40******** *************** @nnrp.fuse.net. .. Hello,
Easiest thing to do IMHO is to make a ref to the SQLDMO.dll and call the method that follows :
SQLDMO.Applicat ion app = new SQLDMO.Applicat ionClass();
SQLDMO.NameList lst = app.ListAvailab leSQLServers();
IEnumerator ie = lst.GetEnumerat or();
while (ie.MoveNext())
{
Debug.WriteLine (ie.Current.ToS tring());
}
HTH, Alex
"Reza Alirezaei" <an*******@disc ussions.microso ft.com> wrote in message news:ut******** ******@TK2MSFTN GP09.phx.gbl... How can I have a list of all sql servers avaiable on our LAN populated in a DropDownList exacly like what we have when we want to specify
Datasource in ADO.Net or wherever?
Thanks
look up the sp_databases stored procedure..
//**
using System.Data;
using System.Data.Sql Client;
private void ListDatabases(s tring serverName)
{
SqlConnection cn = new SqlConnection(" Integrated Security=SSPI;P ersist
Security Info=False;User ID=sa;Initial Catalog=te;Data Source=" + serverName
+ ";");
try
{
cn.Open();
SqlDataReader dr = (new SqlCommand("sp_ databases",
cn)).ExecuteRea der();
}
catch
{
if (cn.State == ConnectionState .Open) {cn.Close();}
return;
}
Console.WriteLi ne("List of [" + serverName + "] SQL Server" );
while (dr.Read())
{
Console.WriteLi ne(dr["DATABASE_N AME"] as string);
}
cn.Close();
}
//***
--
Best Regards
Yanick Lefebvre
"Reza Alirezaei" <an*******@disc ussions.microso ft.com> a écrit dans le
message de news:eH******** ******@TK2MSFTN GP09.phx.gbl... that works fine,,,how can I get a list of databases available on the specified server on a separate Combobox?
"Trebek" <al********@int heformofaquesti on.com> wrote in message news:40******** *************** @nnrp.fuse.net. .. Hello,
Easiest thing to do IMHO is to make a ref to the SQLDMO.dll and call the method that follows :
SQLDMO.Applicat ion app = new SQLDMO.Applicat ionClass();
SQLDMO.NameList lst = app.ListAvailab leSQLServers();
IEnumerator ie = lst.GetEnumerat or();
while (ie.MoveNext())
{
Debug.WriteLine (ie.Current.ToS tring());
}
HTH, Alex
"Reza Alirezaei" <an*******@disc ussions.microso ft.com> wrote in message news:ut******** ******@TK2MSFTN GP09.phx.gbl... How can I have a list of all sql servers avaiable on our LAN populated in a DropDownList exacly like what we have when we want to specify
Datasource in ADO.Net or wherever?
Thanks
doh, didnt see "databases" .
Zoury has it right, also if you want to get more detailed information you
can just hit the sysdatabases table in the master databases, pretty much all
sp_databases is doing.
select * from master.dbo.sysd atabases
Your real problem is that your choice is based off the server selection they
make and the security context your going to connect as. You can either make
them select the server, then enter security info, then pass them as
variables to the sqlconnection string, OR embed trusted or a sql login that
you know has rights to the servers (kinda dangerous).
"Zoury" <ya************ *@hotmail.com> wrote in message
news:u#******** ******@tk2msftn gp13.phx.gbl... look up the sp_databases stored procedure..
//** using System.Data; using System.Data.Sql Client;
private void ListDatabases(s tring serverName) { SqlConnection cn = new SqlConnection(" Integrated Security=SSPI;P ersist Security Info=False;User ID=sa;Initial Catalog=te;Data Source=" +
serverName + ";");
try { cn.Open(); SqlDataReader dr = (new SqlCommand("sp_ databases", cn)).ExecuteRea der(); } catch { if (cn.State == ConnectionState .Open) {cn.Close();} return; }
Console.WriteLi ne("List of [" + serverName + "] SQL Server" ); while (dr.Read()) { Console.WriteLi ne(dr["DATABASE_N AME"] as string); }
cn.Close(); } //***
-- Best Regards Yanick Lefebvre "Reza Alirezaei" <an*******@disc ussions.microso ft.com> a écrit dans le message de news:eH******** ******@TK2MSFTN GP09.phx.gbl... that works fine,,,how can I get a list of databases available on the specified server on a separate Combobox?
"Trebek" <al********@int heformofaquesti on.com> wrote in message news:40******** *************** @nnrp.fuse.net. .. Hello,
Easiest thing to do IMHO is to make a ref to the SQLDMO.dll and call
the method that follows :
SQLDMO.Applicat ion app = new SQLDMO.Applicat ionClass();
SQLDMO.NameList lst = app.ListAvailab leSQLServers();
IEnumerator ie = lst.GetEnumerat or();
while (ie.MoveNext())
{
Debug.WriteLine (ie.Current.ToS tring());
}
HTH, Alex
"Reza Alirezaei" <an*******@disc ussions.microso ft.com> wrote in
message news:ut******** ******@TK2MSFTN GP09.phx.gbl... > How can I have a list of all sql servers avaiable on our LAN
populated in a > DropDownList exacly like what we have when we want to specify Datasource in > ADO.Net or wherever? > > Thanks > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: massimo |
last post by:
Hey,
I wrote this program which should take the numbers entered and sort them
out. It doesn¹t matter what order, if decreasing or increasing.
I guess I'm confused in the sorting part. Anyone has any advices??
#include <iostream>
using namespace std;
|
by: Oliver Braun |
last post by:
I know this is a very common issue and I found a lot of hints on this topic
in www but I did not find a very good solution for this task.
Most of the solutions use SQLDMO to list all sql servers in the network like
this C# code:
public static string GetAvailableSQLServers()
{
// declare arraylist to hold results
ArrayList servers = new ArrayList();
|
by: Kent |
last post by:
Hi!
I want to store data (of enemys in a game) as a linked list, each node will
look something like the following:
struct node
{
double x,y; // x and y position coordinates
struct enemy *enemydata; // Holds information about an enemy (in a game)
// Its a double linked list node
|
by: EvanK |
last post by:
Is there a way to access a list of available sql servers in vb and make a dropdown list?
|
by: Kurt |
last post by:
Hi,
is it possible to get SQL Server list in VB.NET whitout SQLDMO, only with
..NET functions?
Sergio
| |
by: Craig G |
last post by:
without using SQLDMO
is there another way, i've used the SQLDMO way but have had a few issues
with it.
is there another way?
Cheers,
Craig
|
by: Zack Sessions |
last post by:
I am using VB.NET 2003.
I found the following sample code here in an article:
Dim oSQLServerDMOApp As New SQLDMO.Application
Dim i As Integer
Dim namX As SQLDMO.NameList
namX = oSQLServerDMOApp.ListAvailableSQLServers
For i = 1 To namX.Count
|
by: j-in-uk |
last post by:
Can i get a list of sql databases by just connecting to the server
programmatically
string myConnString = "Integrated Security=SSPI;Initial
Catalog={0};Data Source=" + serverName +";";
SqlConnection cn = new SqlConnection(myConnString);
cn.Open();
SqlDataReader dr = (new SqlCommand("sp_databases",
cn)).ExecuteReader();
while (dr.Read())
|
by: querry |
last post by:
Hi all,
I am trying to get a list of all the available sql servers and then populate them in a combo box. I do this with the following code taken from http://www.csharphelp.com/archives2/archive342.html
SQLDMO.Application sqlApp = new SQLDMO.ApplicationClass();
SQLDMO.NameList sqlServers = sqlApp.ListAvailableSQLServers();
for (int i = 0; i < sqlServers.Count; i++)
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |