'A namespace does not directly contain members such as fields or methods'

R

RAO

Hi

I new to C# progrmming. I have taken a sample code from the internet and
try to compile it. I am getting the error

'A namespace does not directly contain members such as fields or methods'

and the code is

----------------------
using System;
using System.Data;
using System.Data.ADO;

Namespace DBAccess
{


public class DBRead
{
public ADODataReader DataReader(string DBStr,string strSQL)
{
// Create the connection
ADOConnection oCn = new ADOConnection(DBStr);
//Create the Command Object
ADOCommand oCm = new ADOCommand(strSQL,oCn);
//Open the connection
oCn.Open();
//Create a null DataReader Object
ADODataReader oDr ;
//Execute the SQL Query
oCm.Execute(out oDr);
// Return the DataReader
return oDr;
}
}
}
----------------------

Any idea what is wrong with this code.

TIA

RAO
 
1

100

Hi RAO,

C# is case sensitive, so the error is that you wrote *Namepsace* with
capital *N*. Write *namespace* instead.

HTH
B\rgds
100
 
J

Jon Skeet

RAO said:
I new to C# progrmming.

In that case, I *strongly* suggest you start with the basics, rather
than diving straight into database access.
I have taken a sample code from the internet and
try to compile it. I am getting the error

'A namespace does not directly contain members such as fields or methods'

C# is case sensitive. Your line:
Namespace DBAccess

should be

namespace DBAccess
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top