使用两个数据集的导航问题 [英] navigation problem with using two dataset

查看:98
本文介绍了使用两个数据集的导航问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我对vb.net有点陌生.

我已经成功开发了一个简单的导航,具有带有绑定控件的"SELECT * FROM CUSTOMERS"之类的按钮,例如上",上",上一个"和下一个".
我的问题始于以下内容:
当使用"SELECT * FROM CUSTOMERS WHERE(CUSTOMERID =?)"并将参数传递给命令时,它将成功运行,但是它显示我的表只有一个记录而不是91个记录,并且仅选择了1个记录,我无法移动到下一个或上一个记录.

我知道这对于sql命令是有意义的,所选内容中只有一条记录,并且数据与"SELECT * FROM CUSTOMERS"绑定,但是我必须在WHERE CLAUSE中使用sql命令.
我无法绑定2个数据集.

有什么方法可以将SQL语句与where子句一起使用,并且仍然设法访问导航中的所有记录?

使用WHERE子句的原因是我也在通过文本框搜索CUSTOMERID并将参数传递给select命令.

我正在使用BOUND CONTROLS.

Hi all,

I''m a bit new to vb.net.

I have successfully developed a simple navigation, having buttons like first, last, previous and next with "SELECT * FROM CUSTOMERS" with bound controls.

My problem begins with following:
When use "SELECT * FROM CUSTOMERS WHERE (CUSTOMERID=?)" and pass the parameters to command it runs successfully but it shows that my table has only one record instead of 91 records, and while only 1 record is selected I can not move to next or previous record.

I know that this makes sense with sql command, only one record in selected and data is bound with "SELECT * FROM CUSTOMERS", but I have to use sql command with WHERE CLAUSE.
I cant bound 2 datasets.

Is there any way that I can use sql statement with where clause and still manage to access all the records in navigation?

The reason of using WHERE clause is that I''m also searching through CUSTOMERID with textbox and passing the parameters in to select command.

I''m using BOUND CONTROLS.

Is this possible with bound controls or I have to use UNBOUND CONTROLS to achieve this task and what would be the code for it?

推荐答案

否.

使用时
No.

When you use
SELECT * FROM Customers WHERE (CustomerId=value)

它仅返回具有"CustomerId"和"value"相同的记录.通常,只有一个客户具有此值(或者您不会知道哪个客户是哪个客户),因此它仅返回一条记录.

有点像银行帐户:

It only returns the records which have a "CustomerId" which is the same as "value". Normally, only one customer will have this value (or you wouldn''t know which customer was which), so it returns a single record only.

It''s a bit like bank accounts:

SELECT * FROM Accounts

将返回该帐户中的每个帐户银行,

Will return every account in the bank,

SELECT * FROM Accounts WHERE (AccountNumber=MyAccountNumber)

只会返回我的详细信息.

Will only return my details.


您不能这样做.如果仍要显示网格中的所有客户,则必须从SQL返回所有客户.您不能为此使用WHERE子句.

现在,如果要确保用户搜索的记录可见,那么您将不得不找到该记录,并使用几种方法之一来使DGV滚动以使该记录可见.阅读 [ ^ ].
You cannot do that. If you still want to show all customers in the grid, you have to return all customers from SQL. You cannot use the WHERE clause for that.

Now, if you want to make sure the record that the user is searching for is visible, then you''re going to have to find that record and use one of several methods for getting the DGV to scroll to make that record visible. Read this[^].


这篇关于使用两个数据集的导航问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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