Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I'm busy building an application with classes.

one class works perfect, so i add a second one.

 

The class compiles great.

But i can't use it in the source of the program, the program gives the following error:

 

The type of namespace name 'statistieken' could not be found (you are missing uing...

 

My class:

 

using System;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Globalization;
using Ini;

namespace WindowsApplication2
{
   class statistieken
   {
       public statistieken()
	{
       }

       static OleDbConnection dbase(OleDbConnection Connection)
       {
           IniFile ini = new IniFile("test.ini");
           string database;
           database = ini.IniReadValue("Info", "Database");

           string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;";
           connectionString += @"Data Source=" + database + ";";

           Connection.ConnectionString = connectionString;
           Connection.Open();

           return Connection;
       }


       public int aantalklanten()
       {
           int hoeveelheid = 0;
           try
           {
               OleDbConnection Connection = new OleDbConnection();
               Connection = dbase(Connection);
               // Create an OleDb command, 
               OleDbCommand myCommand = new OleDbCommand("count (*) from Bedrijven", Connection);
               Connection.Open();
               OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
               while (myReader.Read())
               {
                   hoeveelheid = Convert.ToInt32(myReader.GetString(0));
               }
               Connection.Close();
               return hoeveelheid;
           }
           catch (Exception ex)
           {
               MessageBox.Show("Error: " + ex.Message);
               return hoeveelheid;
           }
       }
   }
}

 

Main source:

 

using customers;
[u]using statistieken;[/u]

private void button1_Click(object sender, System.EventArgs e)
{
           statistieken stats = new statistieken();
           int hoeveelheid = stats.aantalklanten();

 

Whats wrong?

The error is on this line:

 

using statistieken;

 

Thanks... Jelmer

Edited by PlausiblyDamp
  • Administrators
Posted

Is statistieken a namespace in your project or a class? If it is a namespace then it should work, if a class then simply try removing the line.

 

Also if the namespace is part of a seperate project then you need to add a reference to the library or project containing the namespace

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Found the problem.. customers was a seperate project.

That project is added as referance.

 

I like it that its a seperate project, so i've got more dll's..

Is it difficult seperate the classes from the 'big' project ?

 

Its very handy to have everything into the same project during the development

Posted

It still doesnt work..

 

first it was like this:

 

namespace WindowsApplication2
{
   class statistieken
   {
       public statistieken()
	{
       }

 

Now i removed the namespace:

 

    class statistieken
   {
       public statistieken()
	{
       }

 

On the rule

 

using statistieken;

 

The program displays the following error:

 

A using namespace directive can be applied to namespaces, 'statistieken' is a type not a namespace.

 

strange... ?

Posted

sorry problem solved...

 

namespace statistieken
{
   public class Class_statistieken
   {
       public Class_statistieken()
	{
       }

 

and:

 


using statistieken

 

And declare it as Class_statistieken

 

:)

  • Administrators
Posted (edited)

Personally I find the Class_statistieken to be an unusual naming style to say the least and would really try to avoid it.

 

Namespaces are only there to offer you a chance of providing a logical naming scheme to help organise your classes.

I would have simply kept the opriginal class name and just removed the line

using statistieken;

from the source code.

Edited by PlausiblyDamp

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
Personally I find the Class_statistieken to be an unusual niming style to say the least and would really try to avoid it.

 

Namespaces are only there to offer you a chance of providing a logical naming scheme to help organise your classes.

I would have simply kept the opriginal class name and just removed the line

using statistieken;

from the source code.

 

But that doesnt work :S

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...