Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a secured connection string in web.config file and it is running well in my system. But when I am placing application on server then its not reading from web.config file, I mean connection is not establishing.
Please let me know what to do in order to sort out my problem.

thanking you
mohd wasif


Edit: Marked the question solved as mentioned by OP in his comment. - Ankur
Posted
Updated 31-Mar-11 1:36am
v3
Comments
#realJSOP 31-Mar-11 5:55am    
You need to provide EXACT error messages and exceptions. We can't help you when you just say "it's not working".
Sandeep Mewara 31-Mar-11 6:39am    
Not clear. You say it works... and then you say it doesn't.

Edit and update with more details and clearly specify whats happening and when.
Mohd Wasif 31-Mar-11 7:25am    
Question is Solved .
There was hardware error.

1 solution

Set Your Connection String As...


XML
<connectionStrings>
        
        <add name="ConnectionString" connectionString="Data Source=OmPatel\SQLEXPRESS;Initial Catalog=GOLDLOAN;Integrated Security=True"
   providerName="System.Data.SqlClient" />
    </connectionStrings>
    <system.web>



And Retrive In Code Behind As
..

C#
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
con.Open();
// You can have your further code
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900