Click here to Skip to main content
15,907,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I given in webconfig like this
XML
<connectionStrings>
    <add name="sqlconnection" connectionString="Data Source=VANARAJ\SQLEXPRESS;Initial Catalog=Practice; Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>

  </connectionStrings>



Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

C#
Compiler Error Message: CS0103: The name 'ConfigurationManager' does not exist in the current context


Source Error:
C#
Line 19:     protected void btnLogin_Click(object sender, EventArgs e)
Line 20:     {
Line 21:         SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlconnection"].ConnectionString);
Line 22:         con.Open();
Line 23:         SqlCommand cmd = new SqlCommand("select * from UserInformation where UserName =@username and Password=@password", con);
Posted
Updated 20-Sep-13 9:13am
v3
Comments
[no name] 20-Sep-13 12:27pm    
From the documentation: "When you create a project, make sure to add a reference to the System.Configuration assembly. This assembly contains the ConfigurationManager class." Did you?

Add
C#
using System.Configuration;

at the top of your code file.
Also make sure that a reference to System.Configuration.dll is added.
 
Share this answer
 
v2
Use the directive
C#
using System.Configuration;

OR
C#
System.Configuration.ConfigurationManager.ConnectionStrings["sqlconnection"].ToString();


In either case, make sure you have the reference to System.Configuration dll.
HTML
(Add Reference->Assemblies->Framework->System.Configuration )
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900