Now, beyond this, we'll go through the construction of the code line-by-line. The first thing that you need is a connection string. So, let's do the following:
- Open
SQL Server Object Explorer
. - Right-click on the name of your database, in this case
People
, and view itsProperties
. - Then, to get the connection string, make sure that you expand the node called
General
within theProperties
pane, and then go to the one that saysConnection string
and double-click on it to select it with its long description.
- Next, right-click on the long description and copy it. (It's difficult to construct accurately by hand, so it's better just to copy it from there). This procedure is shown in Figure 17.2.2:
Figure 17.2.2: Copying the connection string
- Now, enter the following within the set of curly braces beneath the line that begins with
protected void Button1_Click...
:
string connString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=People;Integrated Security=True;Connect...