2011-05-27 56 views
1

我在RadGrid的Visual Studio 2008中使用Telerik控件。我創建了一個PopUp窗口,其中包含我需要在數據庫中使用的所有TextBoxes和控件,但是如何聲明一個函數以插入,更新和刪除?哪裏?TelerikRadGrid如何插入,更新和刪除到SQL數據庫

+0

什麼是數據庫? – Pankaj 2011-05-27 08:08:09

+0

是的,我正在使用SQL數據庫 – user748057 2011-05-27 08:53:40

回答

0

可以使用Data Access Layer爲定義的函數將請求發送到數據庫

如果你想使用SQL Server。以下是代碼。

using (System.Data.SqlClient.SqlConnection con = new SqlConnection("YourConnection string")) { 
    con.Open(); 
    SqlCommand cmd = new SqlCommand(); 
    string expression = "Parameter value"; 
    cmd.CommandType = CommandType.StoredProcedure; 
    cmd.CommandText = "Your Stored Procedure"; 
    cmd.Parameters.Add("Your Parameter Name", 
       SqlDbType.VarChar).Value = expression;  
    cmd.Connection = con; 
    using (IDataReader dr = cmd.ExecuteReader()) 
    { 
     if (dr.Read()) 
     { 
     } 
    } 
} 

您還可以使用Microsoft Enterprise Library

可以使用Business Logic Layer調用數據庫層功能,並且還可以將數據發送到Presentation Layer

最後才進行驗證,你還可以打電話給Business Logic Layer對象你的Presentation layer

相關問題