---
title: "How can I show the database name to my visitors in MVC4/Razor?"  
description: "How can I show the database name to my visitors in MVC4/Razor?"  
author: "Anonymous User"  
published: 2013-04-03  
updated: 2013-04-03  
canonical: https://www.mindstick.com/forum/702/how-can-i-show-the-database-name-to-my-visitors-in-mvc4-razor  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 1 minute  

---

# How can I show the database name to my visitors in MVC4/Razor?

Hi Everyone!\
I would like to inform my visitors of which [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) they are currently interacting with. My [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) only has a single [Entity Framework](https://www.mindstick.com/articles/1566/crud-operations-using-entity-framework-code-first-approach) connection \
string in it's web.config. The database name (initial catalog) is part of my [connection string](https://www.mindstick.com/articles/328/connection-strings) stored in my web.config.\
I can expose the ENTIRE connection string in the shared layout by including the following html.\
You are connecting to <span class="databasename">@System.Configuration.ConfigurationManager.ConnectionStrings\
["MyConnectionStringName"].ConnectionString)</span>!But I don't need the entire connection string only the database name. Is there a way to do this without involving a [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc) or instantiating a new \
[SqlConnection](https://www.mindstick.com/forum/1209/sqlconnection-sqlcommand-sqldatareader-idisposable)()? Any suggestions?of this given set.\
Is my database bad designed? What would be the best way to do this or how to make the [SELECT query](https://www.mindstick.com/articles/1858/sqlite-select-query)\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by AVADHESH PATEL

Hi John!\
You can try this way\

```
@{    var vDB = new System.Data.SqlClient.SqlConnectionStringBuilder(        System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString)    );    var vName = vDB.InitialCatalog;}
```

\
bind into span <span class="databasename">@vName</span>!\
\


---

Original Source: https://www.mindstick.com/forum/702/how-can-i-show-the-database-name-to-my-visitors-in-mvc4-razor

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
