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
}
}
CodePudding user response:
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);
}