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 8975401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:52:14+00:00 2026-06-15T18:52:14+00:00

This is the working code: static class Global { private static Dictionary<string, int> emails_compsIDs;

  • 0

This is the working code:

    static class Global
    {
        private static Dictionary<string, int> emails_compsIDs;
        private static Dictionary<string, int> set_emails_compsIDs { set { emails_compsIDs = value; } }
        private static DataTable MultiCompReport;

    static Global()
    {
        string e = string.Empty;
        Dictionary<string, int> emails_compsIDs = new Dictionary<string, int>();
        DataTable t = MySql.ExecuteSelect("SELECT Email, Company_ID FROM potencial_contact WHERE Email != '' AND Email IS NOT NULL");

        foreach (DataRow r in t.Rows)
        {
            int comp_id = Convert.ToInt32(r["Company_ID"]);
            e = r["Email"].ToString().Replace("\r", "").Replace("\t", "").Replace("\n", "").Trim().ToLower().Trim();
            if (!string.IsNullOrWhiteSpace(e) && !emails_compsIDs.ContainsKey(e))
            {
                try
                {
                    emails_compsIDs.Add(e, comp_id);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        if (emails_compsIDs.ContainsKey("linda@andatrade.com"))
            Console.WriteLine("Eureka");
        set_emails_compsIDs = emails_compsIDs;
    }
}

But, when I did just emails_compsIDs = new Dictionary<string, int>();
in order to initialize the dictionay in the constructor the code only filled the 1st row into it.
By creating an instance indise the ctor and then putting the result in my static dictionay it filled all the rows.

  • 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-06-15T18:52:16+00:00Added an answer on June 15, 2026 at 6:52 pm

    The error is:

    Dictionary<string, int> emails_compsIDs = ...
    

    Which declares a local variable rather than assigning a static field. It should just be:

    emails_compsIDs = new ...
    

    If that only fills one row, you should step through to find why.

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

Sidebar

Related Questions

Simple question, how make this code working ? public class T { public static
I have this (working) CPU code: #define NF 3 int ND; typedef double (*POT)(double
How do I avoid requiring code like this: public static class BusinessLogicAutomapper { public
This is a learning exercise in expression trees. I have this working code: class
I am working with code that has a global static variable (which is an
I have been trying to get something like this working: private static <V, K>
I have this working java code that serve as the datasource: public final class
I have this working code, but now i need to be able to change
I want to know i can do something similar to this (not working) code
As a beginner in Ocaml, I have this current working code: ... let ch_in

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.