<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : How to get Database Name?</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : How to get Database Name?</description>
  <pubDate>Thu, 11 Jun 2026 13:40:10 -700</pubDate>
  <lastBuildDate>Mon, 03 Dec 2007 21:19:28 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=576</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>How to get Database Name? : The secret to getting the database...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=576&amp;PID=2074#2074</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=23" rel="nofollow">davidklitzke</a><br /><strong>Subject:</strong> 576<br /><strong>Posted:</strong> 03-Dec-2007 at 9:19pm<br /><br />The secret to getting the database name is to get the rdbKey.&nbsp; Here is some code I have often shown to others to get the DatabaseTableName: <BR><DIV><FONT size=2><FONT face="Lucida C&#111;nsole"><FONT size=3><FONT face="Times New Roman"><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal"><?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><O:P>&nbsp;</O:P></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><SPAN style="COLOR: green">Return specified Rdb entity type's DATABASE table name <O:P></O:P></SPAN></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> via a given PersistenceManager.</SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;<O:P></O:P></SPAN></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;param name="pRdbEntityType"&gt;</SPAN><SPAN style="COLOR: green">RdbEntityType whose name may be different <O:P></O:P></SPAN></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> than the corresponding SQL table name.</SPAN><SPAN style="COLOR: gray">&lt;/param&gt;<O:P></O:P></SPAN></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;param name="pManager"&gt;</SPAN><SPAN style="COLOR: green">The PersistenceManager which is our gateway to <O:P></O:P></SPAN></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> the concrete database datasource.</SPAN><SPAN style="COLOR: gray">&lt;/param&gt;<O:P></O:P></SPAN></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;remarks&gt;<O:P></O:P></SPAN></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Includes table owner name, formatted per the applicable SQL provider, e.g. <O:P></O:P></SPAN></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> orderInfo.GetSqlTableName returns "dbo"."MachineSummary".<O:P></O:P></SPAN></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/remarks&gt;<O:P></O:P></SPAN></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">string</SPAN> GetSqlTableName(<SPAN style="COLOR: teal">Type</SPAN> pRdbEntityType, <SPAN style="COLOR: teal">PersistenceManager</SPAN> pManager) {<O:P></O:P></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: teal">RdbKey</SPAN> key = (<SPAN style="COLOR: teal">RdbKey</SPAN>) pManager.DataSourceResolver.GetDataSourceKey(pRdbEntityType);<O:P></O:P></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: teal">RdbQuerySqlFormatter</SPAN> formatter = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: teal">RdbQuerySqlFormatter</SPAN>(key.AdoHelper);<O:P></O:P></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">return</SPAN> formatter.QualifyTableName(pRdbEntityType);<O:P></O:P></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">&nbsp;&nbsp;&nbsp; }<O:P></O:P></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><O:P>&nbsp;</O:P></SPAN></P><P style="MARGIN: 0in 0in 0pt" ="Ms&#111;normal">In a smilar manner, to get the database name, get an RdbKey from the PersistenceManager.&nbsp; From the RdbKey, you can get the connection string.&nbsp; From the connectionstring, &nbsp;you can get the Database (or Host) name.</FONT></FONT></P></FONT></FONT></DIV><span style="font-size:10px"><br /><br />Edited by davidklitzke - 03-Dec-2007 at 9:39pm</span>]]>
   </description>
   <pubDate>Mon, 03 Dec 2007 21:19:28 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=576&amp;PID=2074#2074</guid>
  </item> 
  <item>
   <title>How to get Database Name? : Does anyone know how to get the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=576&amp;PID=2065#2065</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=50" rel="nofollow">JPeacock</a><br /><strong>Subject:</strong> 576<br /><strong>Posted:</strong> 03-Dec-2007 at 1:01pm<br /><br />Does anyone know how to get the name of the database currently connected to?<DIV>&nbsp;</DIV><DIV>The client can choose Database A or Database B to connect to.</DIV><DIV>&nbsp;</DIV><DIV>I'm trying to write some error logging code and I would like to have in the error log information which database the client logged into and if possible some information from the extended properties of the database.</DIV><DIV>&nbsp;</DIV><DIV>Does anyone know if this is possible?</DIV><DIV>If it is where I can find some documentation on how to do it.</DIV><DIV>If there is no documentation provide an example?</DIV><DIV>&nbsp;</DIV><DIV>Thanks</DIV>]]>
   </description>
   <pubDate>Mon, 03 Dec 2007 13:01:46 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=576&amp;PID=2065#2065</guid>
  </item> 
 </channel>
</rss>