473,320 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

getting database name

Adi
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

Jun 20 '07 #1
2 1329
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
--
Milosz
"Adi" wrote:
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

Jun 20 '07 #2
Adi
got it.. thanks milosz..

On Jun 20, 6:05 pm, Milosz Skalecki [MCAD] <mily...@DONTLIKESPAMwp.pl>
wrote:
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
--
Milosz

"Adi" wrote:
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

Jun 21 '07 #3

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

Similar topics

1
by: Oleg Shnayderman | last post by:
Hi All, I am very new to C# as well as to SQL. I need to write an application which is connecting to SQL DB and getting all the user's tables and after create a dataset for all the tables in the...
6
by: Brett | last post by:
Not sure what the problem is here... Trying to update from a datagrid to an access database using vb.net... Its not updating the database but Im not getting any errors... Here is my code... ...
2
by: PHP_Paul | last post by:
Ok, I'm trying to poineer into the wonderful area of PHP/MySQL programming, but I'm having some difficulties. http://www.paulhq.com/php/freepage.html should register, but when anyone fills something...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
0
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.