使用SqlDatareader在DataGridView中添加,编辑,删除记录 [英] Add, edit, delete records in DataGridView using SqlDatareader

查看:82
本文介绍了使用SqlDatareader在DataGridView中添加,编辑,删除记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我创建了一个DataGridView,它使用SqlDataReader从存储过程中提取数据.
如何启用插入,编辑,删除操作并将记录保存到数据库中?

谢谢.

Hello,

I have created a DataGridView that pulls out data from a stored procedure with SqlDataReader.
How can i enable insert, edit, delete actions and saving the records in the db?

Thank you.

推荐答案

您好,

您可以使用 SqlDataAdapter 在数据集的帮助下将更改提交回服务器,以下是几个链接.

如何从数据库更新数据库使用Visual C#2005或Visual C#.NET 的DataSet对象

或者您可以手动完成并指定一个新的不使用SQLCommandBuil的SQLDataAdapter der


我想这全都取决于您项目的实际需求.

Hello,

You can use the SqlDataAdapter with the help of a DataSet to commit the changes back to the server, here are few links.

DataSet Class

How to update a database from a DataSet object by using Visual C# 2005 or Visual C# .NET

Or you can do it manually and specify a new SqlCommand for each action you want to perform.

Some more helpful links:

SQLDataAdapter without using SQLCommandBuilder


I guess it all depends on the actual requirements of your project(s).


这篇关于使用SqlDatareader在DataGridView中添加,编辑,删除记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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