TelerikRadGrid how to insert,update and delete into SQL database

耗尽温柔 提交于 2020-01-05 14:11:24

问题


I am using Telerik controls in Visual Studio 2008, in RadGrid. I create a PopUp windows includes all the TextBoxes and controls that I need to use in database but how can I declare a function in order to insert, update and delete ? And where!?


回答1:


You can use Data Access Layer for Definition of the the function to send the request to database

If you want to use SQL Server. Following is the code.

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()) 
        { 
        } 
    } 
}

You can also use Microsoft Enterprise Library

You can Use Business Logic Layer to call the database layer function and also can perform validations before sending the data to Presentation Layer

Finally, You can call the Business Logic Layer objects in your Presentation layer



来源:https://stackoverflow.com/questions/6149472/telerikradgrid-how-to-insert-update-and-delete-into-sql-database

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!