Read Connection String from Web.Config file in ASP.Net using C# and VB.Net

Read Connection String from Web.Config file in ASP.Net using C# and VB.Net

Today, We want to share with you Read Connection String from Web.Config file in ASP.Net using C# and VB.Net.In this post we will show you c# – Read connection string from web.config, hear for Get ConnectionString From Web.Config File ASP.Net we will give you demo and example for implement.In this post, we will learn about How To Read And Write Connection String In Web.Config? with an example.

In this post, we will learn about how to Read Connection String from Web.Config file in ASP.Net using C# and VB.Net with an example.

Now in this post, I will explain how to Read Connection String from Web.Config file in ASP.Net using C# and VB.Net with appropriate example. In ASP.Net Web applications, it requires reference to the System.Configuration Assembly in order to read Connection String value from the Web.Config file.

C# VB.Net Read Connection String from Web.Config file in ASP.Net

First, you need to add the Connection String in the ConnectionStrings section of the Web.Config file in the following way.


    
        
    

Now,you can read the Connection String value by its name from the Web.Config file in the following way.

Get Dynamically connection string in app.config file c#

C# :

string connectionStr = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;

VB.Net :

Dim connectionStr As String = ConfigurationManager.ConnectionStrings("ConString").ConnectionString

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about C# VB.Net Read Connection String from Web.Config file in ASP.Net.I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment