Chap. 9, Dorknozzle, "Configuration Manager"


I’m doing the Dorknozzle project from the “BUILD YOUR OWN ASP.NET 3.5 WEB SITE USING C# & VB, 3RD EDITION” book. And I’m still very much a beginner.

The code looks like this (without the “”):

SqlConnection conn;
SqlCommand comm;
SqlDataReader reader;
string connectionString =
conn = new SqlConnection(connectionString);
comm = new SqlCommand(
“SELECT EmployeeID, Name, Username FROM Employees”,
reader = comm.ExecuteReader();
employeesRepeater.DataSource = reader;

There’s a red line under the “ConfigurationManager.ConnectionStrings[” as if something’s wrong. When I try to “View in browser” I get this message:

“Compiler Error Message: CS0103: The name ‘ConfigurationManager’ does not exist in the current context”

The book says: “To retrieve configuration data from Web.config, we use the
ConfigurationManager class, which is located in the System.Configuration namespace.”

That class is nowhere to be found, and I’m still a beginner, so I have no idea how to add it myself (if that’s even possible?). I’ve tried to take the books “Web.config”-file but it’s not there either.

Anyone have a clue, what I should do in this situation? It’s quite important that I’ll be able to move on, because this book is a part of the stuff I have to know, at my exam next week :stuck_out_tongue:

Thanks in advance

Christopher, Denmark

Fixed. It is the book that fails. It’s not a part of the code I’ve written here.

It should be:

using System.Data.SqlClient
using System.Configuration

and not just:

Imports System.Data.SqlClient, as the book says.

Not Imports System.Data.SqlClient. using System.Data.SqlClient, ofc.

Glad that you could figure out the answer your own question… well done :tup: