Hi,
Is there any standard string method to find out the database name from the connection string..
Thanks
Once you're connected, SELECT DB_NAME()
http://www.aspfaq.com/
(Reverse address to reply.)
"DbQuester" <anonymous@.discussions.microsoft.com> wrote in message
news:C4725B60-6FD5-4DCA-BE75-D2839E3B53D9@.microsoft.com...
> Hi,
> Is there any standard string method to find out the database name from the
connection string..
> Thanks
|||ok thanks, but wouldnt it be better to have the database name right in the app, instead of telling t-sql to talk to the database and then give out the result.. my connection string will be in app.config file and I want to just split it out and use info li
ke InstanceName and database etc all throughtout my app..
thanks
|||(a) If you're already connected to the database, SELECT DB_NAME() is not
going to be any more of a performance hit than string parsing. And it's
still something you only have to do once.
(b) In your app config file, keep the parameters you want separate and then
build the connection string in the app. This way you can keep certain
attributes in separate variables.
(c) There is no magic string parser that will look at a connection string
and tell you certain attribute values. You can use regular expressions, but
see (a).
http://www.aspfaq.com/
(Reverse address to reply.)
"DbQuester" <anonymous@.discussions.microsoft.com> wrote in message
news:CCB255A7-DF84-4BB4-B121-4975FE7C38B0@.microsoft.com...
> ok thanks, but wouldnt it be better to have the database name right in the
app, instead of telling t-sql to talk to the database and then give out the
result.. my connection string will be in app.config file and I want to just
split it out and use info like InstanceName and database etc all throughtout
my app..
> thanks
|||Thanks, it makes sense..
|||1. You could create a UDL and test it against the SQL Server/DB in question.
2. Then open the UDL as a notepad and copy the connection string which you
can use for app's init file.
Cheers,
Vikram Jayaram
Microsoft, SQL Server
This posting is provided "AS IS" with no warranties, and confers no rights.
Subscribe to MSDN & use http://msdn.microsoft.com/newsgroups.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment