I'm using VS2010 on XP.
Below is the app.config file i'm trying to use. I don't understand the part about the connection string. I have two calls to the database that uses this same connection string, but i don't know how to use it.
I know I can access the <add key=""> values with the following code.Code:<?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="ConnectionString" providerName="System.Data.SqlClient" connectionString="Data Source = cwsqldb; Initial Catalog = Annuals; Integrated Security = True" /> </connectionStrings> <appSettings> <add key="fromAddress" value="[email protected]"/> <add key ="ToAddress" value ="[email protected]"/> <add key="ToBcc" value="[email protected]"/> <add key="subject" value="codeworth Connection Audit Alert"/> <add key ="smtp" value="mail88-gwy"/> </appSettings> </configuration>
But how do i access the connection string? I don't understand that block of code AT ALL! I understand that the connection string is composed of different parts. But i've always seen it as basically one long string separated by semicolons.Code:string fromAddress = ConfigurationManager.AppSettings["fromAddress"].ToString(); string ToAddress = ConfigurationManager.AppSettings["ToAddress"].ToString();
Thanks for your help!




Reply With Quote