473,320 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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

Nov 15 '05 #1
2 24891
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
"RAO" <na*********@hotmail.com> wrote in message
news:O4****************@TK2MSFTNGP12.phx.gbl...
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

Nov 15 '05 #2
RAO <na*********@hotmail.com> wrote:
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

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
1
by: John L. Clark | last post by:
I am curious as to the rationale, and effect, of having default namespaces not applying (directly) to attributes (see http://www.w3.org/TR/REC-xml-names/#defaulting). Given an attribute without a...
27
by: Ron Adam | last post by:
Hi, I found the following to be a useful way to access arguments after they are passed to a function that collects them with **kwds. class namespace(dict): def __getattr__(self, name): return...
3
by: Dharma | last post by:
Hello, I am trying to compile this "hello world" program but it gives me this following error, "A namespace does not directly contain members such as fields or methods" Can someone pelse help me...
5
by: Genboy | last post by:
My "VIS" Website, which is a C# site created in VS.NET, Framework 1.1, is no longer compiling for me via the command line. As I have done 600 times in the last year and a half, I can compile to...
4
by: Peter Speybrouck | last post by:
I have a little problem with a webservice. I reproduced the problem in the following simplified example. I just create a new C# ASP.NET webservice and a c# console application. I added a new...
6
by: ryan.d.rembaum | last post by:
Hello, I have code that I wish to use in many web applications. Basically sort of stand utility stuff. So from Visual Studio Project I select add a component and chose Component Class. Lets...
1
by: Mark Denardo | last post by:
Ok here's my problem: I have a bunch of Classes at the same namespace level say "abc.xyz". And all Classes reside in different files. abc.xyz.Class1 (in Class1.vb) abc.xyz.Class2 (in...
11
by: Raja Chandrasekaran | last post by:
Hai folks, I have a question to get exact answer from you people. My question is How Static class is differ from instance class and If you use static class in ASP.NET, ll it affect speed or...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.