TelerikRadGrid 如何在 SQL 数据库中插入、更新和删除 [英] TelerikRadGrid how to insert,update and delete into SQL database

查看:30
本文介绍了TelerikRadGrid 如何在 SQL 数据库中插入、更新和删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Visual Studio 2008 的 RadGrid 中使用 Telerik 控件.我创建了一个弹出窗口,包括我需要在数据库中使用的所有文本框和控件,但是如何声明一个函数以插入、更新和删除?在哪里!?

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!?

推荐答案

您可以使用数据访问层 for 定义向数据库发送请求的函数

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

如果您想使用 SQL Server.以下是代码.

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

您还可以使用 Microsoft Enterprise Library

可以使用业务逻辑层调用数据库层函数并且还可以在将数据发送到 Presentation Layer

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

这篇关于TelerikRadGrid 如何在 SQL 数据库中插入、更新和删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆