Jelmer Posted February 5, 2006 Posted February 5, 2006 (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 February 5, 2006 by PlausiblyDamp Quote
Administrators PlausiblyDamp Posted February 5, 2006 Administrators Posted February 5, 2006 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 Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jelmer Posted February 5, 2006 Author Posted February 5, 2006 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 Quote
Jelmer Posted February 5, 2006 Author Posted February 5, 2006 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... ? Quote
Jelmer Posted February 5, 2006 Author Posted February 5, 2006 sorry problem solved... namespace statistieken { public class Class_statistieken { public Class_statistieken() { } and: using statistieken And declare it as Class_statistieken :) Quote
Administrators PlausiblyDamp Posted February 5, 2006 Administrators Posted February 5, 2006 (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 February 5, 2006 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jelmer Posted February 5, 2006 Author Posted February 5, 2006 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 Quote
Administrators PlausiblyDamp Posted February 5, 2006 Administrators Posted February 5, 2006 If you remove that line what error does it give then? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.