How do you set the app.config and web.config connection strings?

Jul 12, 2008 at 11:52 PM
Hi there,

I have been trying all day to connect to my db with a account I have created. I keep getting errors when attempting to connect to the database through web.config connection

Error stack: [SqlException (0x80131904): Login failed for user 'sa2'.]

Summary of steps which led up to the error

So, I created account sa2 to just match the same type account used to access data like Omar did in his app.config file. To make things easier, I decided on not putting a password just to let the connection work.

The Server name is Dashboard but in management studio it looks like Dashboard\ihatelag  within this server scope I have created a db called dropthings (which is the restored db from the dropthings.bak which came with the project)

The connection string I used in the web.config file is the following:

<connectionStrings>
        <add name="DashboardConnectionString" connectionString="Data Source=localhost;Initial Catalog=Dashboard\ihatelag;user id=sa2;" providerName="System.Data.SqlClient"/>
    </connectionStrings>
   
The string I used in the app.config file is the following

<connectionStrings>
        <add name="DashboardDataAccess.Properties.Settings.DashboardConnectionString" connectionString="Data Source=localhost;Initial Catalog=Dashboard\ihatelag;User ID=sa2;"
            providerName="System.Data.SqlClient" />
    </connectionStrings>

Can someone help me with the correct way to write these strings in both app.config and web.config. Your help and advice is most appreciated!

Many thanks in advance!





Jul 17, 2008 at 8:34 PM
Issue fixed, found a tutorial about the connection strings, compiles and works now :)