Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

getting database name

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Adi - 20 Jun 2007 21:19 GMT
hi everyone... i have a doubt.. is there any way i can get the
database name.. my page is accessing.. i would like to display the
database name, the current page is accessing. This has to be done
without refering to the connection string which is usually used to
create the connection with the database. i would appreciate for the
help..
thanks
ADITYA
Milosz Skalecki [MCAD] - 21 Jun 2007 00:05 GMT
Hi there Adi,

two ways:

1.  
string database = ((IDbConnection)myConnection).Database;

2.
SqlCommand command = new SqlCommand("SELECT DB_NAME();", connection);
string database = (string) command.ExecuteScalar();

or use SqlDataSource with SelectCommand property set to "SELECT DB_NAME()"

hope this helps
Signature

Milosz

> hi everyone... i have a doubt.. is there any way i can get the
> database name.. my page is accessing.. i would like to display the
[quoted text clipped - 4 lines]
> thanks
> ADITYA
Adi - 21 Jun 2007 15:50 GMT
got it.. thanks milosz..

> Hi there Adi,
>
[quoted text clipped - 21 lines]
> > thanks
> > ADITYA

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.