2009-06-13 74 views
0

我加了下面這段代碼:如何在ADO.NET實體框架中運行存儲過程?

public partial class Form1 : Form 
{ 
    TestAdonetEntity2Entities entityContext; 
    public Form1() 
    { 
     InitializeComponent(); 
     entityContext = new TestAdonetEntity2Entities(); 
    } 

    private void Form1_Load(object sender, EventArgs e) 
    { 
     dataGridView1.DataSource = entityContext.SelectMyCustomer(); 
    } 
} 

但這個代碼將導致錯誤:

public global::System.Data.Objects.ObjectResult<MyCustomer> SelectMyCustomer() 
{ 
    return base.ExecuteFunction<MyCustomer>("SelectMyCustomer"); 
} 

的錯誤是:

An error occurred while executing the command definition. See the inner exception for details.

我的存儲過程...:

ALTER procedure [dbo].[proc_MyCustomer] 
as 
begin 
    select * from dbo.MyStuffs 
end 

周我的專欄: 客戶ID PK墨
名稱爲nvarchar(50)
姓爲nvarchar(50)

+0

什麼是在你的InnerException? – 2009-06-13 18:19:46

回答