shieldguy
asked on
How to read the connection string value from the web.config
How can I read the value of the connectionstring1 from the web.config file in the asp.net to create connetion object
Thanks
Thanks
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="connectionstring1" connectionString="Server=ABCServerName;Database=Db1;User ID=sa;Password=abc;Trusted_Connection=False;Min Pool Size = 9;Max Pool Size = 80" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
..........
..........
..........
you may like to remove the localdatabase, in case it may conflict with the connection:
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="connectionstring1" connectionString="Server=ABCServerName;Database=Db1;User ID=sa;Password=abc;Trusted_Connection=False;Min Pool Size = 9;Max Pool Size = 80" providerName="System.Data.SqlClient"/>
</connectionStrings>
ASKER
which classes i need to import as i am getting errors
on Configuration and ConnectionStringsSection
error is type expected
on Configuration and ConnectionStringsSection
error is type expected
I am importing these classes in my dbconnection class:
Imports System.Web.Configuration
Imports System.Data
Imports System.Data.SqlClient
Just for the getting the connection string from the web config you need:
Imports System.Web.Configuration
Imports System.Web.Configuration
Imports System.Data
Imports System.Data.SqlClient
Just for the getting the connection string from the web config you need:
Imports System.Web.Configuration
ASKER
Can I use some other way as I might use this code in the vb.net desktop application so it will be problem when I am calling the Imports System.Web.Configuration later
ASKER
I think this solution is not stuitable with my code can someone give me the other way to read this connection please so I would be able to read the value in vb.net application
thanks
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great thats the solution which I am looking for
Thanks
Thanks
Dim ConnectionString As ConnectionStringsSection = CType(WebConfig.GetSection
dim strConnectionString = ConnectionString.Connectio