简体   繁体   中英

Cannot implicitly convert type 'System.Collections.Generic.List<ValueObjectLayer.booksVAL>' to 'int'

I'm trying to make a 3 layered C# Library Management project.

I'm trying to select a book from bookDAL (dataacceslayer) through booksBLL(businesslogiclayer and show it on winforms.

i get this error message on BLL error

DAL:

    public static List<booksVAL> BookSelect(string x)
    {
        List<booksVAL> sonuc = new List<booksVAL>();
        OleDbCommand cmdkitaplistele = new OleDbCommand("select * from books where id = " + Int32.Parse(x) + " ", dbConnection.conn); // 
        if (cmdkitaplistele.Connection.State != ConnectionState.Open) // bağlantı açık değise
        {
            cmdkitaplistele.Connection.Open(); // bağlantıyı aç
        }

        OleDbDataReader dr = cmdkitaplistele.ExecuteReader(); // sorgu sonuçlarını data reader ile oku
        while (dr.Read())
        {
            booksVAL book = new booksVAL();
            book.bookId = int.Parse(dr["id"].ToString());
            book.bookName = dr["bookname"].ToString();
            book.bookAuthor = dr["authorname"].ToString();
            book.bookPagecount = dr["pagecount"].ToString();
            book.bookDatepublished = dr["datepublished"].ToString();
            book.bookIsavailable = dr["isavailable"].ToString();
            book.bookCategory = dr["category"].ToString();
            sonuc.Add(book);
        }
        dr.Close();
        return sonuc;
    }

BLL:

public static int BookSelect(string x)
{
    return booksDAL.BookSelect(x);

Form:

public partial class bookupdateForm : Form
{
   booksForm f1;
    public bookupdateForm(booksForm frm1)
    {
        InitializeComponent();
        this.f1 = frm1;
        booksBLL.BookSelect(f1.selectedlabel.Text); // selectedlabel comes from another form, it works

    }
}

Problem is here:

public static int BookSelect(string x)
{
    return booksDAL.BookSelect(x);
}

Change return type int to List<booksVAL> :

public static List<booksVAL> BookSelect(string x)
{
    return booksDAL.BookSelect(x);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM