奇怪的静态类问题
下面是我非常简单的静态类。不知道出了什么问题。 我在一个具有正确“using”语句的非静态类中使用它。智能感知看到类及其一种方法。
我收到错误
名称“SQLUserDataManager”不 存在于当前上下文中”。
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";
}
}
更新: 这是我正在使用它的行。
SQLUserDataManager.SpecifyConnection("admin", "password", "Users");
问题已解决
我有一个 DLL,其中包含编译时出错的文件。在这个 DLL 中,我还没有包含包含该文件的新文件。我包含了该文件,一切都很好! ^_^
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! ^_^
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
错误发生在哪里?
SQLUserDataManager 类是否位于另一个命名空间中,然后是您引用 SQLUserDataManager 的类?
Where does the error occur ?
Is the SQLUserDataManager class in another namespace then the class where you refer to SQLUserDataManager ?
静态和非静态几乎肯定是无关紧要的——尽管如果您能向我们展示您如何尝试使用它将会有所帮助。
这是在 ASP.NET 中吗?我想知道这是否与 ASP.NET 最终构建的方式以及哪些代码位于何处有关。您能给我们提供更多详细信息吗?
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?