Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
sir, iam a fresher and iam getting the following error and could't solve myself please help me out
MYCODE IN DAL IS
namespace DAL
{
public class DalEmployee
{
SqlConnection con = new SqlConnection("data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|Database1.sdf;User Instance=true");
public DataSet ds; SqlDataAdapter da; SqlCommandBuilder bldr;
public DalEmployee()
{
da = new SqlDataAdapter("Select * from Employe", con);
ds = new DataSet();
da.Fill(ds, "Employee");
da.FillSchema(ds, SchemaType.Source, "Employee");
bldr = new SqlCommandBuilder(da);
}
public void UpdateDB()
{
da.Update(ds, "Employee");
}
}
}
MYCODE IN BLL IS
CSS
using DAL;

namespace BLL
{
    public class BllEmployee
    {
        int Esalary, Eid, Edeptno; DataRow Rec;
        string Ename, Edesignation; DateTime Edoj;
        DalEmployee objdal = new DalEmployee();

        public int PEid
        {
            set { Eid = value; }
            get { return Eid; }
        }
        public string PEname
        {
            set { Ename = value; }
            get { return Ename; }
        }
        public string PEdesignation
        {
            set { Edesignation = value; }
            get { return Edesignation; }
        }
        public DateTime PEdoj
        {
            set { Edoj = value; }
            get { return Edoj; }
        }
        public int PEsalary
        {
            set { Esalary = value; }
            get { return Esalary; }
        }
        public int PEdeptno
        {
            set { Edeptno = value; }
            get { return Edeptno; }
        }
        BllEmployee obj = new BllEmployee();
        public void InsertRec()
        {
here    ->->  Rec = obj.ds.Tables[0].NewRow();// Here iam getting the error s
                    Rec[0] = Eid;
                    Rec[1] = Ename; 
        }

->->// BLL.BllEmployee does not contain a definition for ds and no extension method ds accepting afirst argument of type BLL.BllEmployee' could be found(are you missing a using directiveor an seeembly reference?)
Here iam not getting the dataset ds;
Posted
Updated 13-Dec-13 1:57am
v4
Comments
BillWoodruff 13-Dec-13 6:33am    
While there are many possible reasons this code fragment ... a class without a Constructor shown ... won't work, there's no mystery in the error message: 'ds is not defined anywhere.
Mike Meinz 13-Dec-13 6:37am    
Using BllEmployee obj = new BllEmployee();, you are instantiating class BllEmployee within class BllEmployee. Are you trying to do some kind of recursion for some reason?

You have no ds method in class BllEmployee.
Tom Marvolo Riddle 13-Dec-13 6:40am    
Virtual 5!

Hello!

This error means that the variable/property ds is not defined in the class BllEmployee.

If you have the source code to BllEmployee, you could change it to add whatever sort of variable ds is supposed to refer to.

Unfortunately I have no idea from your question what ds is supposed to actually be...


@Mike Meinz - good point! :-)

You need to define whatever ds is supposed to be yourself.
 
Share this answer
 
v2
Well...it doesn't.
There is no definition of a DataSet anywhere in your class, much less one called "ds", so it is quite correctly saying "You can't do this: ds does not exist as a member of this class"

Did you mean to use objdal instead of obj?
 
Share this answer
 

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