Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1020615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:11:19+00:00 2026-05-16T11:11:19+00:00

My connection string is placed in web.config as follows. <connectionStrings> <add name=empcon connectionString=Persist Security

  • 0

My connection string is placed in web.config as follows.

<connectionStrings>
   <add name="empcon" connectionString="Persist Security Info=False;User ID=sa;Password=abc;Initial Catalog=db5pmto8pm;Data Source=SOWMYA-3BBF60D0\SOWMYA" />
</connectionStrings>

and the code of program is…

public partial class empoperations : System.Web.UI.Page
{

    string constr = null;

    protected void Page_Load(object sender, EventArgs e)

    {
        ConfigurationManager.ConnectionStrings["empcon"].ToString();
         if (!this.IsPostBack)
        {
            fillemps();
        }
    }
    public void fillemps()
    {
        dlstemps.Items.Clear();
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["empcon"].ConnectionString);
        con.ConnectionString = constr;
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = "select * from emp";
        cmd.Connection = con;
        SqlDataReader reader;
        try
        {
            con.Open();
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                ListItem lt = new ListItem();
                lt.Text = reader["ename"].ToString();
                lt.Value = reader["empno"].ToString();
                dlstemps.Items.Add(lt);
            }
            reader.Close();
        }
        catch (Exception er)
        {
            lblerror.Text = er.Message;
        }
        finally
        {
            con.Close();
        }        

i am totally new to programing….

i am able to run this application with er.message in label control as “the connection string property has not been initialized”

i need to retrieve the list of names of employees from the emp table in database into the dropdownlist and show them to the user…

can any one please fix it…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:11:20+00:00Added an answer on May 16, 2026 at 11:11 am

    You are not assigning ConfigurationManager.ConnectionStrings["empcon"].ToString(); to string constr

    protected void Page_Load(object sender, EventArgs e)
    {
        constr = ConfigurationManager.ConnectionStrings["empcon"].ToString();
        ...
    

    will probably solve your problem for the time being.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

heelo this is my connection string <connectionStrings> <add name=DefaultConnection connectionString=Data Source=.\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True providerName=System.Data.SqlClient;Password=;User
I am trying to add <location inheritInChildApplications=false> to my parent web application's web.config but
Is it safe to write connection string in web.config in an ASP.net application. The
I have web application and and DB connection settings are stored in web.config The
How can <connectionStrings> in Web.config be changed without resetting sessions of logged in users?
I'm trying to set up a connecting string in my web.config file (Visual Studio
In connection string to SQL Server there is max pool size option. My question
I've checked the connection string (I got it from the server explorer). I've checked
I have the following connection string: Data Source=localhost\\SQLEXPRESS; , it complains that '' is
I have the following connection string, and you will notice Provider's.Tests, notice the single

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.