Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi All

 

I need a bit of help and advice, up untill now my .NET programs have used old ADO for data access, I am now trying to convert them to ADO.NET and am wondering If some of the things I am doing are correct.

 

The project I am working on is an Accounts/Stock/MRP/Costing and Warehouse system, all the main data access forms use the same layout, that is you go into form, it loads the data and then displays the first record. You can step through the data using buttons, Begining of File, Precious, Next , End of File and Find, in ADO 2.7 you could use the MoveFirst, MoveLast etc calls to get the records.

 

In ADO.NET I have created my DataAdapter that has filled a DataSet and has given me a DataTable that I can work on.

Now the book I am learning from says to use the DataRow object to navigate around the table ie

 

rowPRJEmp = tblPRJEmp.Rows[RowToDisplay]

 

I have used RowCount to get the number of records, and RowToDisplay is set at 0 to start with, then as they go through the table I +/- RowToDisplay or set it to 0/RowCount.

 

My problem is when they find a record, again I have a set find form that will return the Primary key for the record they want, I then use tblPRJEmp.Rows.Find to get that record.

 

I have two questions

 

1) How do I get the row number from the table for the record I have just found.

 

and

 

2) Am I going about this the right way, it just seems a lot more complicated and long winded than ADO 2.7

 

I have tried reading the book again and looking at the help but my brain seems to have turned to mush, I can see the letters and words but they no longer make any sense.

 

Any help/advice would be most appreciated.

 

Thanks

Posted

Thank you for the reply Robby.

 

I don't believe in Databinding controls either , I prefer to have more control, but the book I am using does talk about this and It seems that I would have the same problem, you can use CurrencyManager.Position to move about the table (Same as I am doing now with a Current Row Pointer) but although it shows BOF, EOF, Next and Previous there seems to be nothing for a Find method so I would not be any better off.

 

I could get around this by making a routine to start at record one and count each record untill it finds the one they want or change the interface so that it comes up with a list first, both of these work arounds I would rather avoid.

 

So if someone knows of a way to return the row index for the record you are looking at I would be most appreciated.

 

Thanks

Posted

I have just finished testing a way of doing it, I add a column to my Datatable and set AutoIncrement to true, that way I always have an index (plus 1) for the row.

 

Robby I don't know much about Dataview as have never used it but will have a look at what it can do.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...