Online Resources for Web Developers and Professionals - BETA

  search

Exam : MCSD - Developing and Implementing Web Applications with Microsoft Visual Basic.NET..

Creating Connection with SQL SERVER 2000 using ASP.NET

You are a Web developer for ABC . You create an ASP.NET application that accesses sales
and marketing data. The data is stored in a Microsoft SQL Server 2000 database on a server
named ABC 01.
The company purchases a factory automation software application. The application is installed
on ABC 01, where it creates a second instance of SQL Server 2000 named Factory and a
database named FactoryDB. You connect to FactoryDB by using Windows Integrated
authentication.
You want to add a page to your ASP.NET application to display inventory data from
FactoryDB. You use a SqlConnection object to connect to the database. You need to create a
connection string to FactoryDB in the instance of SQL Server named Factory on ABC 01.
Which string should you use?
 
A. "Server= CertK 01;Data Source=Factory;
Initial Catalog=FactoryDB;Integrated Security=SSPI"
B. "Server= CertK 01;Data Source=Factory;
Database=FactoryDB;Integrated Security=SSP1"
C. "Data Source= CertK 01\Factory;Initial Category=Factory;
Integrated Security=SSP1"
D. "Data Source= CertK 01\Factory;Database=FactoryDB;
Integrated Security=SSP1"

 
Answer: D

 

Explanation:


The Data Source attribute of the connection string contains the name, instance or
network address of the instance of SQL Server to which to connect. In this scenario we are to
connect to the Factory Instance on ABC 01 so we use ABC 01\Factory as data source.
To specify the database we should either use the Database or the Initial Catalog attribute. Here we
use Database=FactoryDB.
Note: The SQL Server .NET Data Provider provides connectivity to Microsoft SQL Server version
7.0 or later using the SqlConnection object. The connection string includes the source database
name, and other parameters needed to establish the initial connection.
Reference:
.NET Framework Class Library, SqlConnection.ConnectionString Property [Visual Basic]
Incorrect Answers
A, B: We can user either the Server attribute or the Data Source property, but not both.

References:


No reference found
Prev 1  2  3  Next

Exam related books