Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

.net - Equivalent of MoveNext in VB.NET

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...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...