03.11.2016 Views

Beginning ASP.NET 4.5 in CSharp and VB Opsylum

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Configur<strong>in</strong>g SQL Server 2012 x 795<br />

Choos<strong>in</strong>g between W<strong>in</strong>dows <strong>and</strong> Server Authentication<br />

In general, it’s recommended to use W<strong>in</strong>dows Authentication when possible. The fact that you don’t<br />

need to use a password <strong>in</strong> the connection str<strong>in</strong>g means your application will be a bit safer. You don’t<br />

need to send the password over the wire, <strong>and</strong> it’s also not stored <strong>in</strong> a configuration file for your<br />

application.<br />

However, SQL Server Authentication is a bit easier to set up. Because you specify the username<br />

<strong>and</strong> password explicitly, you don’t need to know the f<strong>in</strong>al user account that your application runs<br />

under.<br />

Later <strong>in</strong> this appendix you see how to use both authentication mechanisms to connect to your database.<br />

However, you need to look at someth<strong>in</strong>g else first: the tools used to manage SQL Server.<br />

Us<strong>in</strong>g SQL Server Management Studio<br />

You use SQL Server Management Studio to manage your SQL server <strong>and</strong> databases. It enables you<br />

to attach <strong>and</strong> detach databases to your SQL Server; create new database objects like tables <strong>in</strong> exist<strong>in</strong>g<br />

databases; select, create, edit <strong>and</strong> delete data; <strong>and</strong> much more.<br />

So far, you’ve been us<strong>in</strong>g the LocalDB version of SQL Server, the developer-friendly version of SQL<br />

Server. In addition to LocalDB, Microsoft has another free version of SQL Server called SQL Server<br />

Express. The follow<strong>in</strong>g sections of this appendix show you how to work with this free SQL Server<br />

Express edition, because it’s very similar <strong>in</strong> use compared to its commercial <strong>and</strong> production-ready<br />

databases. If you only <strong>in</strong>stalled LocalDB, you need to download <strong>and</strong> <strong>in</strong>stall SQL Server Express<br />

along with the free SQL Server Management Studio Express. The section, “Install<strong>in</strong>g SQL Server<br />

2012 Express,” <strong>in</strong> Chapter 12 expla<strong>in</strong>s how to acquire SQL Server 2012 Express Edition as well as<br />

its Management Studio component.<br />

If you are already us<strong>in</strong>g a commercial version of SQL Server, you already have access to the full version<br />

of SQL Server Management Studio, because it comes bundled with the database eng<strong>in</strong>e.<br />

If you are hav<strong>in</strong>g trouble connect<strong>in</strong>g to a remote SQL Server (for example, an <strong>in</strong>stance of SQL<br />

Server that is not on the same physical server as the one on which you’re runn<strong>in</strong>g Management<br />

Studio), you may need to enable remote connections for that SQL Server first. This is discussed next.<br />

Enabl<strong>in</strong>g Remote Connections <strong>in</strong> SQL Server<br />

When work<strong>in</strong>g with SQL Server, you may receive an error stat<strong>in</strong>g that the server was not found, not<br />

accessible, or that remote connections may not be configured properly.<br />

Although you may get this error when the database server is down, you also get this error when<br />

SQL Server is not configured for remote connections. In a default <strong>in</strong>stallation, SQL Server allows<br />

only local applications to connect <strong>and</strong> blocks remote connections automatically. To resolve this, <strong>and</strong><br />

grant remote systems access to the server as well, follow these steps:<br />

1. Open the SQL Server Configuration Manager from the Start menu or Start screen. Depend<strong>in</strong>g<br />

on the version of SQL Server you’re us<strong>in</strong>g, this item may be located under the Microsoft SQL<br />

Server 2012/Configuration Tools submenu.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!