473,938 Members | 45,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

retrieve list of databases from .net

Can i get a list of sql databases by just connecting to the server
programmaticall y

string myConnString = "Integrated Security=SSPI;I nitial
Catalog={0};Dat a Source=" + serverName +";";
SqlConnection cn = new SqlConnection(m yConnString);
cn.Open();
SqlDataReader dr = (new SqlCommand("sp_ databases",
cn)).ExecuteRea der();
while (dr.Read())
{
lstDatabases.It ems.Add(dr["DATABASE_N AME"]);
}

This does not work cos I don't know the name of database/initial
catalog at this point

Jan 4 '07 #1
2 1695
"j-in-uk" <je******@gmail .comwrote in message
news:11******** **************@ 51g2000cwl.goog legroups.com...
This does not work cos I don't know the name of database/initial
catalog at this point
Yes you do - it's called 'master' :-)
Jan 4 '07 #2
Thanks, master worked. I am using NetServerEnum to get a list of the
sqlServers, I realise that this does not return sqlExpress servers but
get everything else. Do you know what returns SQLExpress & other sql
servers?

thanks

On Jan 4, 1:52 pm, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
"j-in-uk" <jessn...@gmail .comwrote in messagenews:11* *************** ******@51g2000c wl.googlegroups .com...
This does not work cos I don't know the name of database/initial
catalog at this pointYes you do - it's called 'master' :-)
Jan 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
3029
by: Daniel Tonks | last post by:
First, please excuse the fact that I'm a complete MySQL newbie. My site used forum software that I wrote myself (in Perl) which, up until now, has used flat files. This worked fine, however lately I've been wanting to do more stuff with user accounts, and had been eying MySQL for over a year. Finally I've decided to start off small by converting the forum's account system to a MySQL database (and convert the rest later after I'm...
3
7776
by: Amit | last post by:
Hi when I try to run LIST ACTIVE DATABASES AT DBPARTITIONNUM <partnum> or LIST ACTIVE DATABASES GLOBAL, I always get an error message. Does anyone know why? I'm on v8 fp 5 output : db2 => list active databases at dbpartitionnum 1; SQL0104N An unexpected token "1" was found following "<identifier>". Expected tokens may include: "GLOBAL". SQLSTATE=42601 db2 => list active databases at GLOBAL;
11
36099
by: Chuck | last post by:
Is there a command that will list all of the databases for a particular instance on the local machine, whether they are activated or not? If there is no such command, is there at least a way to list only the local databases in the db directory, and tie them back to the instance they belong to? -- Chuck Remove "_nospam" to reply by email
2
1725
by: tranky | last post by:
Hi.... .....i'd like to know if there's a way to write in a textbox the schema of a database. numbers of tables, tables name, numbers of fields, fields name and other information like fields type, etc... is it possible? i hope... please help me... thank you.
4
2555
by: Andy M | last post by:
ALERT There is a person by the name of Mike Cox who's trying to turn this mailing list into a Big-8 newsgroup. Many of you know that this and most of the other postresql mailing lists are already gated to Google Groups and a small number of private news servers. If Mike Cox succeeds, this list will be available as a newsgroup on a great many more ISPs and NSPs, which could be a good or a bad thing. For one, e-mail addresses on this
13
2215
by: no.mail.pls | last post by:
Hiya, How do i retreive fields with similar values from 2 tables? I tried to use (1) "SELECT * FROM $table1 as o , $table2 as p WHERE o.name like '%p.name%'"; but it retrieves nothing at all. (2) "SELECT * FROM $table1 as o , $table2 as p WHERE o.name like p.name";
4
5837
by: serge | last post by:
http://www.csharphelp.com/archives2/archive342.html I am using the sample code from this link but I am unable to figure out how to retrieve the list of the User-Defined Functions. I am able to get the count of the user defined functions correctly using: db.ListObjects(SQLDMO.SQLDMO_OBJECT_TYPE.SQLDMOObj_UserDefinedFunction, SQLDMO.SQLDMO_OBJSORT_TYPE.SQLDMOObjSort_Name).Count
3
13509
by: Fran | last post by:
(SQL 2005) I'm looking to create a stored procedure to first "select name from sys.databases where name like '%site'" then pass each name to the following using some kind of loop "USE @name select name from sys.tables where type = 'U'" I tried a while statement, but the master sys.databases recordset doesn't change.. It's the loop I can't get to work.
5
25607
by: Ken | last post by:
I'm trying to run a loop to capture column property information from a table in my datasource. Can anybody see where this is going wrong? Dim tbl As New DataTable Dim col As DataColumn Dim x As Integer Dim colName(99) As String Dim colType(99) As String cn.Open() tbl = cn.GetSchema("Orders") 'Orders is a table in the
0
10126
marktang
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...
0
9963
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,...
0
11512
Oralloy
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...
0
9853
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8209
isladogs
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...
0
6072
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...
0
6286
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4442
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3495
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.