Skip to main content
CSharpUniversity ASP.NET and C# lessons

The search runs entirely in your browser over the published lesson list.

Making the database reachable from your site

A database that only works on the local machine with the management tool is not yet ready for a web application. Two settings bridge the gap.

Turn on the network protocol

By default the free engine may have shared memory enabled and network access disabled. For a web application on the same machine that is often enough, but for anything else you must enable the protocol and allow the port through the firewall.

Build a connection string

Config
Server=.\SQLEXPRESS;
Database=Shop;
Trusted_Connection=True;

What each part does

  • The server names the instance. A dot means this computer.
  • The database names which database to open.
  • The trusted connection line uses the current Windows account instead of a stored password.
Keep credentials out of shared files. Store the connection string in configuration, never hard coded in a page, and never commit a real password to a shared folder.

With a working connection, create some data in creating a database and some test rows.

New lessons by email

Leave your address and get a short note whenever a fresh lesson is published. No account needed and you can stop at any time.

Thank you. Your address has been noted in this browser session. Connect a mailing service to deliver the notes for real.