C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




List of Databases


Posted Date: 08 May 2008    Resource Type: Code Snippets    Category: ADO.NET

Posted By: Debasmit Samal       Member Level: Gold
Rating:     Points: 7



The following code sample is an effective way to obtain the list of all databases.


void GetDatabases ()
{

StringBuilder sda = new StringBuilder();
String strConnection = "Put your connection string in detail";
using (SqlConnection sqlCon = new SqlConnection(strConnection))
{
sqlCon.Open();
DataTable tblDatabasesNmaes = sqlCon.GetSchema("Databases");
sqlCon.Close();

foreach (DataRow row in tblDatabasesNmaes.Rows)
{
String strDatabaseName = row["database_name"].ToString();
sda.Append(" : " + strDatabaseName);
}
}
MessageBox.Show(sda.ToString());

}


To have some kind of output, we use a message box to show the list. There are other ways too. For example, the string can be added to a listbox, etc.




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Show database names  .  Show all databases  .  Obtain all databases  .  List databases  .  Get database names  .  Enlist database names  .  Databases list  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Simple program to add/delete data to database
Previous Resource: Get Number of rows affected by SqlDataSource / ObjectDataSource select Query
Return to Discussion Resource Index
Post New Resource
Category: ADO.NET


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

masks masks masks

Contact Us    Privacy Policy    Terms Of Use