无法将类型 'System.Collections.Generic.List<ValueObjectLayer.booksVAL>' 隐式转换为'int'



我正在尝试制作一个3层的C#库管理项目。

我正试图从bookDAL(dataacceslayer(到bookBLL(businesslogicallayer(中选择一本书,并在winforms.上显示

我在BLL上收到这个错误消息错误

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);

形式:

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
}
}

问题就在这里:

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

将返回类型int更改为List<booksVAL>:

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

相关内容

  • 没有找到相关文章

最新更新