且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

不包含定义,并且没有可以找到接受类型的第一个参数的扩展方法(您是否缺少using指令或引用?)

更新时间:2022-12-08 19:49:58

你好!



这个错误意味着变量/ property ds 未在BllEmployee类中定义。



如果您有BllEmployee的源代码,您可以更改它以添加任何类型的变量ds应该是指。



不幸的是我不知道你的问题是什么 ds 应该是是...




@Mike Meinz - 好点! :-)



你需要定义自己应该是​​什么ds。


嗯...它没有。

类中没有DataSet的定义,更像是一个名为ds的定义,所以它非常正确地说你不能这样做:ds不作为成员存在这个班级



你的意思是使用 objdal 而不是 obj

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

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;

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.


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?