Here's a great overview on MSDN that covers how to do this.
In your web.config, add a connection string entry:
<connectionStrings>
<add
name="MyConnectionString"
connectionString="Data Source=sergio-desktop\sqlexpress;Initial
Catalog=MyDatabase;User ID=userName;Password=password"
providerName="System.Data.SqlClient"
/>
</connectionStrings>
Let's break down the component parts here:
Data Source is your server. In your case, a named SQL instance on sergio-desktop
.
Initial Catalog is the default database queries should be executed against. For normal uses, this will be the database name.
For the authentication, we have a few options.
User ID and Password means using SQL credentials, not Windows, but still very simple - just go into your Security section of your SQL Server and create a new Login. Give it a username and password, and give it rights to your database. All the basic dialogs are very self-explanatory.
You can also use integrated security, which means your .NET application will try to connect to SQL using the credentials of the worker process. Check here for more info on that.
Finally, in code, you can get to your connection string by using:
ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString