Error: The name 'SqlHelper' does not exist...


In VS 2005, C#, ASP.NET 3.0, I am getting the following error when trying to build my solution:

Error 1 The name 'SqlHelper' does not exist in the current context d:\work\cwork\pool\pooling\pooling\pooling.cs 25 28 pooling

It's a simple console application test solution with only 2 cs files:

pooling.cs
SqlHelper.cs

SqlHelper is supposed to be a class file.

Pooling.cs contains the main method as follows:
**********
static void Main(string[] args)
{
while (true)
{
// error line
SqlDataReader dr = SqlHelper.ExecuteReader(connString,
CommandType.Text, "select date = getdate()");
// error line
if (dr != null)
{
while (dr.Read())
{
Console.WriteLine(dr["date"].ToString());
}
dr.Close();
}
Console.WriteLine("Press Enter to continue...\n");
Console.ReadLine();
}
}

********

In the SqlHelper.cs file, the class is as follows:

********
using .....;

namespace pooling
{
public class SqlHelper
{
private static Int32 NUM_TRIES ;
private const Int32 MAX_TRIES = 32;

static SqlHelper()
{
NUM_TRIES = 0;
}

//VARIOUS CODE
}

*********
How can I make SqlHelper 'visible' to the pooling.cs file?

Many thanks
Mike Thomas

[1340 byte] By [MThomas] at [2007-12-25]
# 1
SqlHelper is in different namespace then pooling. So check namespace, and if you don't want to change it, then you should fully qualify the SqlHelper class. That is pooling.SqlHelper.ExecuteReader. One other suggestion, if you need only one value from result then use ExecuteScalar method.
boban.s at 2007-8-31 > top of Msdn Tech,Visual C#,Visual C# General...
# 2
Many thanks Boban - you were right, I was using two different namespaces.
Mike Thomas
MThomas at 2007-8-31 > top of Msdn Tech,Visual C#,Visual C# General...