TableAdapter等不按照我希望的方式工作...... [英] TableAdapter and such not working the way I had hoped...

查看:61
本文介绍了TableAdapter等不按照我希望的方式工作......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在使用C#和SQL Server 2005来处理这个项目...我将在每个安装本地拥有数据库......过去几周我一直在SQL中创建存储过程Server 2005和现在我已经转移到C#并将数据库连接到C#,因此我可以获取/修改/删除数据/等。无论如何......我显然错过了对DataSet和TableAdapter如何工作的理解,而且我在过去的一天里花了我的头发没有结果。所以我有这个存储过程叫做





Code Snippet

解决方案

< font face = Arial size = 2>我的理解是你要么使用存储过程,要么使用tableAdapter而不是两者。当您拥有tableAdapter时,您可以在程序占用空间中拥有所有表,以便立即访问和操作数据。 TableAdapter非常容易实现,因为它们是设计器中的组件,但它们有一个缺点:如果您的数据很大,您将把所有表都放在RAM中,但也许您的直接需求将仅限于更新一条记录。



因此,存储过程旨在在SQL Server上进行所有计算和数据选择,过滤等。我不是100%肯定,但也许您的错误消息与您打开连接并同时尝试通过SP访问相同表格这一事实有关。


< p align = left>


所有的说法和完成,也许可能会出现两种情况,例如你通过SP访问另一个表。一个表通过tableAdapter连接,但您还需要其他表。 SQL SB中可能还有系统SP,而您可能会在全局或其他地方执行某些统计信息。我不认为你的情况属于这种类型。



我希望它有意义。


So I'm working on this project using C# and SQL Server 2005...I'm going to have the database locally for each installation...I've been spending the past couple of weeks created stored procedures in SQL Server 2005 and now I've moved on to C# and connecting the database to C# so I can grab/modify/delete data/etc. Anyways...I'm apparently missing an understanding on how DataSets and TableAdapters work and I've spent that past day pulling out my hair with no result. So I have this stored procedure called

Code Snippet

解决方案

It is my understanding that you either use stored procedures or tableAdapter but NOT both. When you have a tableAdapter you do have all your tables in your program footprint for immediate access and data manipulation. TableAdapters are very easy to implement because they are components in the designer but they have a drawback: if your data is huge you will have all your tables in your RAM but perhaps your immediate needs will be confined to just updating one record.

 

Therefore the stored procedures were designed to make all calculations and data selection, filtering, etc at the SQL Server. I am not 100% certain but perhaps your error message has something to do with the fact that you have a connection opened and at the same time you are trying to access the same tables via a SP.

 

All said and done, perhaps there might be situations where you may use both, for instance you access another table via SP. One table is connected via tableAdapter but you need something else. Also there might be system SPs in SQL SB whereas you may perform some statistics globally or whatnot. I don't think your situation is of this type.

 

I hope it makes sense.


这篇关于TableAdapter等不按照我希望的方式工作......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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