skates008
skates008

Reputation: 191

working with 3 tier in winform

In my BLL class I'm trying to make an instance of the DAL class. But thos shows an error on following line:

DAL obj = new DAL();

What am I doing wrong? Although I have kept a reference of the DAL class in BLL. This is the error-message:

'DAL' is a 'namespace' but is used like a 'type

Here's my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace BLL
{
    public class Class1
    {
        public void Insert(string fname, string lname, string alias, int contact, string address, string company, string bdate, string email)
        {
            DAL obj = new DAL();

            try  
            {  
                obj.Insert( fname, lname,alias, contact,address,company,bdate,email);
            }  
            catch (Exception ex)  
            {  
                throw ex;  
            }  
        }  
    }
}

Upvotes: 0

Views: 84

Answers (1)

Abbas
Abbas

Reputation: 14432

You don't have a class BLL, you have a namespace named BLL. The class you have in this namespace is Class1. Probably you're making the same mistake with DAL, meaning it is also a namespace and not a class. Here's how it should look:

DAL:

namespace DAL
{
    public class Database
    {
        public void Insert(string name, string alias, ...)
        {
            //Logic here
        }
    }
}

BLL:

using DAL;

namespace BLL
{
    public class Repository
    {
        public void Insert(string name, string alias, ...)
        {
            Database _obj  = new Database();
            //Logic here
        }
    }
}

Upvotes: 1

Related Questions