的SqlCommand或SqlDataAdapter的? [英] SqlCommand or SqlDataAdapter?

查看:165
本文介绍了的SqlCommand或SqlDataAdapter的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建类似的东西,保持记录的客户,员工,服务,销售,并任命一个小出纳应用程序。我使用的是Windows窗体,并且DataGrid的范围内。我创建了我将使用应用程序的数据库。我想知道我是否应该使用SqlCommand的-SqlDataReader的或SqlDataAdapter的-数据集来代替。哪种方法更好呢?

I'm creating something like a small cashier application that keeps record for the clients, employees, services, sales, and appointments. I'm using windows forms, and within that DataGrids. I've created the database that I'm going to be using for the application. I want to know if I should use SqlCommand-SqlDataReader or SqlDataAdapter-DataSet instead. Which approach is better?

推荐答案

这是高度取决于你想要的操作类型。

This is highly depend upon type of operation you want.

以下是我suggetion。

Following is my suggetion.

  1. 如果你想更快的读取数据去SqlDataReader的,但自带的经营成本,你需要服用 之后也是在读。 打开连接 读取数据 关闭连接。如果你忘了关比将达到的性能。

  1. If you want to read data faster go for SQLDataReader but that comes as cost of operation you need to take during read after that also. Open Connection Read Data Close Connection. If you forgot to close than it will hit performance.

去的SqlDataAdapter

Go for SQLDataAdapter

  • 如果你想读的速度更快,使用断开拱门利益。 ADO.net的
  • 这将自动关闭/打开连接。
  • 此外,它也可以让你在DataSet中自动处理更新回数据库。 (SqlCommandBuilder)

使用的SqlCommand(这也来当你阅读SqlDataReader的读取数据)和插入和更新。

Use SQLCommand ( This will also comes when you read SQLDataReader for read data) and for insert and update.

  • 这会给你的插入和更新更好的性能。

如果您使用的是.NET框架3.5 SP1或更高版本,我建议LINQ到SQL或实体框架也将 解决你的目的。

If you are using .NET Frame 3.5 sp1 or later i would suggest Linq to SQL or Entity Framework would also solve your purpose.

感谢。

这篇关于的SqlCommand或SqlDataAdapter的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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