Click here to Skip to main content
15,169,823 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi All,

Im trying to create a class, but i keep on getting this error.

Error 1 'GatePass.clsDSLApp.clsDSLApp()' must declare a body because it is not marked abstract, extern, or partial


here is the code below, please assist.

Error 1 'GatePass.clsDSLApp.clsDSLApp()' must declare a body because it is not marked abstract, extern, or partial C:\Users\Monde\Documents\Visual Studio 2008\Projects\GatePass\GatePass\clsDSLApp.cs 9 16 GatePass

C#
namespace GatePass
{
    public class clsDSLApp : clsDSLBase
    {
        public clsDSLApp();

        public bool FillComboBoxDataSet(ref ComboBox cboComboBox, DataSet dsRecords, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, int intConnectionIndex, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, string strConnectionString, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxXML(ref ComboBox cboComboBox, string strXMLFileName, string strSQL, int intConnectionIndex, bool blnRecreateXML, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);


}
}
Posted
Comments
ZurdoDev 26-Feb-14 10:42am
   
What are you trying to do? What are all your FillComboBox... things? They are not declared properly. They look like method definitions but there is no {} body to them.
BillWoodruff 26-Feb-14 12:35pm
   
You are very confused about what Classes, and Methods, are; you need to get a book on C# and study these.

You don't have to "predeclare" methods like you do in C: so replace teh semicolon with curly brackets to create an empty constructor:
C#
public class clsDSLApp : clsDSLBase
    {
        public clsDSLApp() {}

        public bool FillComboBoxDataSet(ref ComboBox cboComboBox, DataSet dsRecords, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, int intConnectionIndex, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, string strConnectionString, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxXML(ref ComboBox cboComboBox, string strXMLFileName, string strSQL, int intConnectionIndex, bool blnRecreateXML, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
}
Or, to have exactly the same effect, just delete the line!
C#
public class clsDSLApp : clsDSLBase
    {
        public bool FillComboBoxDataSet(ref ComboBox cboComboBox, DataSet dsRecords, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, int intConnectionIndex, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, string strConnectionString, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
        public bool FillComboBoxXML(ref ComboBox cboComboBox, string strXMLFileName, string strSQL, int intConnectionIndex, bool blnRecreateXML, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
}
An empty constructor will be created for you behind the scenes.
   
Comments
Nicholas Marty 26-Feb-14 10:47am
   
The problem would still persist here as the other methods are declared in the same manner :)
You can't declare methods like this (This is c# not C or C++, so no need for prototyping :))

You need to write those methods like this:
C#
namespace GatePass
{
    public class clsDSLApp : clsDSLBase
    {
        public clsDSLApp() {
            // Do STuff
        }       
 
        // Do other methods likewise
    }
}


or create an interface instead of a class:
C#
namespace GatePass
{
    public interface clsDSLApp
    {

         bool FillComboBoxDataSet(ref ComboBox cboComboBox, DataSet dsRecords, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
         bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, int intConnectionIndex, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
         bool FillComboBoxSQL(ref ComboBox cboComboBox, string strSQL, string strConnectionString, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex);
         bool FillComboBoxXML(ref ComboBox cboComboBox, string strXMLFileName, string strSQL, int intConnectionIndex, bool blnRecreateXML, int intDisplayMemberColumnIndex, int intValueMemberColumnIndex); 
    }
}


You could also declare the class as abstract and thus force other classes inheriting this class to implement them etc.
   
v3
Comments
ndeza 26-Feb-14 11:21am
   
Thank you Nicholas will try it out and let you know.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900