VB.NET 中 MoveNext 的等价物 [英] Equivalent of MoveNext in VB.NET

查看:24
本文介绍了VB.NET 中 MoveNext 的等价物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于 VB.NET 中不再提供 Recordset.MoveNext 功能(在互联网上搜索了很多),我想要一种方法来解决我的问题..

(使用 MSSQL,刚刚在某处看到了 SQLDATASET 不支持的 movenext 函数.)

我想使用类似 MoveNext 功能的东西并立即在数据库中进行更改.此外,在进行更改后,它也应该立即反映到数据库中..
正如我所说,我在互联网上搜索了很多,我现在很困惑该使用什么......
我在网上得到的以下选项

1)使用 SQLDataset 并与它一起使用 SQLDataAdapter
问题:- 我必须每次都更新数据集,因为我希望主数据库在数据集中发生变化时立即发生变化.

2)使用 DataReader,类似于 while rdr.read()(很多人建议这样做.)
问题:- 但我也想在数据库中更新,而阅读器只是读取数据库.如果我使用 dataAdapter 连同它来更新数据库,那么它将保持连接打开一段时间.

3) 我在某处看到的一些 Data bindingNavigator 功能,但无法获得.如果此选项是不错的选择,请在评论中添加链接...

如果可能,请提出任何其他选择...

注意:- 这个问题有点讨论类型(但不是讨论),这可能是不允许的,但它可能对我有帮助....如果问题不合适,那么在得到一些好的建议后,我会关闭它...

提前谢谢...

解决方案

在UI中,可以使用

As Recordset.MoveNext function is no longer available in VB.NET(searched alot on internet), I want a way to solve my problem..

(Using MSSQL, just seen movenext function somewhere which is not supported with SQLDATASET.)

I want to use something which work like MoveNext function and make the changes in the database instantly. Moreover after changes made, it should also reflect into database instantly..
As I said, I searched alot on internet, I am now confused what to use...
The following options I got on Internet

1)Using SQLDataset and use SQLDataAdapter with it
Problem :- I have to update the dataset everytime because I want instant change in main database as it change in dataset.

2)Using DataReader, something like while rdr.read()(many people suggested this.)
Problem :- But I also want to update in database and reader just read the database.. If I use dataAdapter along with this to update database then it'll keep the connection open for sometime.

3) Some Data bindingNavigator function I seen somewhere but can't get it. If this option is good option then please add a link in comment plz...

Please suggest any other option if possible...

Note:- The question is somewhat discussion type (but its not discussion) which is not allowed maybe but it might help me.... If its not appropriate question then after getting some good suggestions, I'll close it...

Thanx in advance...

解决方案

In UI, you can use BindingNavigator. In code, you can use BindingSource.MoveNext() or change this.BindingContext[datasource].Position.

OP: Some Data bindingNavigator function I seen somewhere but can't get it. If this option is good option then please add a link in comment plz...

As a quick start to create a data application:

  1. Show Data Source Window from menu View > Other Windows > Data Sources or by using its shortcut Shift+Alt+D.
  2. Create a new DataSet with the Data Source Configuration Wizard. In the wizard, choose Database as data source type, and follow the wizard, connect to database and select table(s) which you want to use.
  3. After creating the DataSet, Open a form, then go to Data Source Window and Set the Control to be created when dragging from the Data Sources Window. If you choose details mode in Data Source Window, for each field of table a control will be placed on the form. If you choose DataGridView mode, DataGridView will be placed on the form.

  4. Then drag a table name and drop it on the form. Some controls and some codes will be added to the form. You can run the form and it loads data and you can navigate between records using BindingNavigator or change data and at last save changes by click on save button.

Note:

  • It shows data because the designer generated some codes to fill datasets by using TableAdapters.

  • It saves data becase the designer generated some codes to save data back to the database

  • It uses a BindingNavigator to navigate between records and show buttons for add, remove and save.

  • It uses a BindingSource control to to simplify the process of binding controls to an underlying data source. The component has methods and properties for sorting, filtering and navigation.

  • It uses a DataSet as a complete set of data including the tables that contain, order, and constrain the data, as well as the relationships between the tables.

这篇关于VB.NET 中 MoveNext 的等价物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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