Í build a class file.
But a little problem.
I like it that the class has a function that returns something (an integer in this case) to the main file.
So this is the incorrect part of my class:
It shoud not be a void i guess.. but i forgot what it must be..
Inside the class i use this for example, that works:
The class is named: Class_customers:
Class_customers klant = new Class_customers();
So i like to use this kind of code:
int counting;
counting = klant.aantal_klanten();
Whats the correct syntax ?
Gr. Jelmer
But a little problem.
I like it that the class has a function that returns something (an integer in this case) to the main file.
So this is the incorrect part of my class:
Code:
public void aantal_klanten()
{
int hoeveelheid;
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);
}
}
It shoud not be a void i guess.. but i forgot what it must be..
Inside the class i use this for example, that works:
Code:
static OleDbConnection dbase(OleDbConnection Connection)
The class is named: Class_customers:
Class_customers klant = new Class_customers();
So i like to use this kind of code:
int counting;
counting = klant.aantal_klanten();
Whats the correct syntax ?
Gr. Jelmer