我正在嘗試制作一個 3 層 C# 庫管理專案。
我正在嘗試通過booksBLL(businesslogiclayer)從bookDAL(dataacceslayer)中選擇一本書,并將其顯示在winforms上。
我在 BLL錯誤上收到此錯誤訊息
達爾:
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;
}
布萊爾:
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
}
}
uj5u.com熱心網友回復:
問題在這里:
public static int BookSelect(string x)
{
return booksDAL.BookSelect(x);
}
將回傳型別更改int為List<booksVAL>:
public static List<booksVAL> BookSelect(string x)
{
return booksDAL.BookSelect(x);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/398331.html
下一篇:組合框Winforms
