views:

99

answers:

2

Below is my very simple static class. Not sure what is wrong. I am using it in a non static class that has a correct "using" statement. Intellisense sees the class and its one method.

I am getting the error

The name 'SQLUserDataManager' does not exist in the current context".

public static class SQLUserDataManager
    {
        public static SqlConnection connection;
        private static bool connectionMade;

        static SQLUserDataManager()
        {


        }

        public static void SpecifyConnection(string username, string password, string database)
        {

            string connectionString = "user id=" + username +
                                        ";password=" + password + ";server=127.0.0.1" +
                                        ";Trusted_Connection=yes" +
                                        ";database=NetunityUsers" +
                                        ";connection timeout=30";

        }
    }

Update: This is the line I am using it in.

 SQLUserDataManager.SpecifyConnection("admin", "password", "Users");

Problem Solved

I have a DLL that includes the file that was having errors compiling. In this DLL I had yet to include my new file which contains this file. I included the file and all is good! ^_^

+1  A: 

Where does the error occur ? Is the SQLUserDataManager class in another namespace then the class where you refer to SQLUserDataManager ?

Frederik Gheysels
The error occurs in a ctor for another class that is not static.I have pasted the relevent line in my OP.
bobber205
+1 Most likely the problem, the rest of the code looks fine.
Zyphrax
A: 

The staticness and non-staticness are almost certainly irrelevant - although it would help if you could show us how you're trying to use it.

Is this in ASP.NET, by any chance? I wonder whether it's to do with the way that ASP.NET ends up being built, and what code lives where. Could you give us more details?

Jon Skeet
It is not ASP.NET.Just a regular C# project.
bobber205
Okay, that's very odd then. And you see it in intellisense, but then compilation fails? And this is within the same project?
Jon Skeet