Technical-Talk banner
Home   About Us   Contact Us
Question:
You are an ASP.Net developer and creating an ASP.Net page showing a list of Stocks. The Stocks data is stored in Microsoft SQL Server, you use SqlConnection object to connect to the database. Here is the information regarding Stocks data:
. SQL server computer name is TechTalk
. The database where stock data is stored is named TechTalkStkDB
. The table where Stock information is stored is named Stocks.
. You use the following username and password to connect to the TechTalkStkDB: User: TechApp Password: TechTalk011
You need to set the connection string for the SqlConnection object, which string should you use?
A. “Provider=SQLOLEDB.1;File Name =”Data\MyFile.udl
B. “Provider=MSDASQL;Data Source= TechTalk; Initial Catalog= TechTalkStkDB; User ID= TechApp;Password= TechTalk011”
C. “Data Source= TechTalk;Initial Catalog= TechTalkStkDB; User ID= TechApp;Password= TechTalk011”
D. “Data Source= TechTalk;Database= TechTalkStkDB; Initial File Name=Products;User ID= TechApp;Pwd= TechTalk011”



Correct Answer: C
Explanation:
We specify the name of the SQL Server computer with the Data Source attribute. The database is specified with the Initial Catalog attribute.
Incorrect Answers
A, B: The SqlConnection.ConnectionString has no Provider attribute. The provider is implicitly SQL Server 7.0 or later.
D: There is no Initial File name attribute in the SqlConnection.ConnectionString. This attribute makes the connection string invalid.

Google