[英]System.Data.EntityException' occurred in System.Data.Entity.dll
今天,當我在Visual Studio中運行我的c尖銳項目時,出現了此錯誤
“ System.Data.Entity.dll中發生” System.Data.EntityException“。基礎提供程序在打開時失敗。
在運行良好的幾天之前,這是我的代碼中出現錯誤。 有人請幫助我。
private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
{
dataGridView1.CurrentRow.HeaderCell.Value = dataGridView1.CurrentRow.Index + 1;
label2.Text = "";
dbcontext = new BookDatabase.BooksEntities();
var bookName = Convert.ToString(dataGridView1.CurrentRow.Cells[1].Value);
var book = from bok in dbcontext.Books
where bok.Title == bookName
select bok;
foreach (var bk in book)//Showing problem here, highlighting book
{
dataGridView1.CurrentRow.Cells[0].Value = bk.Code;
dataGridView1.CurrentRow.Cells[2].Value = bk.Edition;
var auto = from autho in bk.Authors
select autho;
foreach (var author in auto)
dataGridView1.CurrentRow.Cells[3].Value = author.FirstName + " " + author.LastName;
dataGridView1.CurrentRow.Cells[4].Value = bk.Price;
}
}
它提供內部異常嗎? 通常更具體。 驗證您的數據庫服務器處於聯機狀態,並且您的連接字符串正確。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.