assume your project is called xyz
(a) in vs2008, click Project, xyz Properties...
(b) a tab labelled xyz will open; click Settings
(c) you will likely see a link in the centre of your screen:
===> This project does not contain a default settings file. Click here to create one.
(d) click the above link.
(e) your xyz tab will change to xyz* because you are modifying it.
You should see a database like grid:
Name Type Scope Value
Setting string Application
(f) change "Setting" to "ConnString"
Name Type Scope Value
ConnString string Application
(g) change "string" to "(Connection string)" using the drop down list under "Type"
Name Type Scope Value
ConnString(Connection string) Application
(h) click in the "Value" column, you will see [...] to the far right. Click the [...] button.
(i) The "Choose Data Source" dialog opens. Click "Microsoft SQL Server".
Clear the check box "Always use this selection" at the bottom of the "Choosew Data Source" dialog.
(j) make sure that the "Date provider" drop down is set to ".NET Framework Data Provider for SQL Server".
(k) click "Continue" to open the "Connection Properties" dialog.
(l) Data source will likely be "Microsoft SQL Server (SqlClient)".
(m) click the drop down by "Server name:" and select your server,
example: yourComputerName\SQLEXPRESS
(n) choose your authentication method under "Log on to the server",
example: "Use Windows Authentication".
(o) with "Connect to a database name:" selected, click the drop down list below it,
then choose your database, example "Northwind".
(p) click the [Test Connection] button in the lower left hand corner of the "Connection Properties" dialog.
IMPORTANT: success at this point is indicated only if you see a message box that says "Test connection succeeded".
Click [ OK ] to close the "Test connection succeeded" message box.
(q) click [ OK ] to close the "Connection Properties" dialog.
(r) your should now see a connection string in the Value column, example:
Data Source=yourComputerName\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True
(s) save your changes, example Ctrl+s, the xyz* tab will become xyz to indicate that your save was successful.
(t) for an ASP.NET MVC project, you should see this under your Web.config settings:
<connectionStrings>
<add name="xyz.Properties.Settings.ConnString" connectionString="Data Source=yourComputerName\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
Regards,
Gerry (Lowry)