Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Connection Strings

Posted on 2007-11-28
4
Medium Priority
?
508 Views
Last Modified: 2008-02-01
This is not an exam or homework

You have created the following connection string entry in the web.config:
<connectionStrings>
<add name="TestConnectionString" connectionString="Data Source=Test;Datbase=Test;UID=google;Password=google" providerName="System.Data.SQLClient"/>
<connectionStrings>

Which of the following code segments reads the connection string information from the web.config and assigns it to a SQLConnection object?

1.
Imports System.Configuration
Imports System.Data.SqlClient
...
Dim con As New SqlConnection
con.ConnectionString = ConfigurationManager.ConnectionStrings("TestConnectionString")
 
2.
Imports System.Configuration
Imports System.Data.SqlClient
...
Dim con As New SqlConnection
con.ConnectionString = ConfigurationManager.RetrieveConnectionString("TestConnectionString")
 
3.
Imports System.Configuration
Imports System.Data.SqlClient
...
Dim con As New SqlConnection
con.ConnectionString = ConfigurationManager.GetConnectionString("TestConnectionString")
 
4.
Imports System.Configuration
Imports System.Data.SqlClient
...
Dim con As New SqlConnection
con.ConnectionString = ConfigurationManager.ConnectionStrings("TestConnectionString").ConnectionString
0
Comment
Question by:cybernation989
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 20364235
Dim rootWebConfig As System.Configuration.Configuration
    rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/MyWebSiteRoot")
Dim connString As System.Configuration.ConnectionStringSettings
If (0 < rootWebConfig.ConnectionStrings.ConnectionStrings.Count) Then
    connString = rootWebConfig.ConnectionStrings.ConnectionStrings("NorthwindConnectionString")
    If Not (Nothing = connString.ConnectionString) Then
        Console.WriteLine("Northwind connection string = {0}", connString.ConnectionString)
    Else
        Console.WriteLine("No Northwind connection string")
    End If
End If
0
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 1000 total points
ID: 20364238
0
 
LVL 7

Expert Comment

by:Infinite_Recursion
ID: 20364702
this is funny, why don't you just post the whole exam to save us time
0
 
LVL 5

Assisted Solution

by:rajups
rajups earned 1000 total points
ID: 20365020
Hi,
1 is the correct answer.

All the best,
Raju P. S
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question