Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Would you please help? I put connection string in my web.config

My web.config:
<configuration>
<connectionstrings>
<add name="mywork_str">
connectionString="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=mywork-PC;Initial Catalog=homework;Data Source=myDB"/>



<system.web>
<compilation debug="true" strict="false" explicit="true" targetframework="4.0">



in my source code:Visual 2010 professional (Visual Basic)

Dim myConnectionString As String = System.Configuration.ConfigurationManager.ConnectionStrings["mywork_str"].ConnectionStrings.Tostring

ERROR I get:
Identifier expected , the underline placed under " (double quote) of ["mywork_str"]

Anyone knows how to fix it . I am so appreciated

Thanks

Charlie
Posted

Thanks you all.

I have replaced ["mywork_str"] === > ("mywork_str") and it is working...
 
Share this answer
 
Comments
♥…ЯҠ…♥ 23-Sep-13 1:16am    
;-)
Hi,

I think the connection string name you have given as different in web.config
Connection string in your web.config should look like this....
XML
<add name="mywork_str" connectionstring="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=mywork-PC;Initial Catalog=homework;Data Source=myDB" />

Otherwise change the name of the connection string that matches the string that you have gave in server side code(mywork_str).
I hope this helps you a bit.

Regards,
RK
 
Share this answer
 
C#
string connStr = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;

Try like this..
 
Share this answer
 
I would try putting brackets or single quotes around the userid in the connectionstring, Since it has that dash.
 
Share this answer
 

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