|
-
Oct 8th, 2002, 04:59 AM
#1
Thread Starter
New Member
This Seems Like It Should Be Simple....
Hi,
This seems like it should be simple, but I cannot figure it out!
I have the "Standard Code" to create a DataSet, as shown below....
Dim objConnection As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=C:\Temp\DataBaseAccess\db1.mdb")
Dim objDataAdapter As New OleDb.OleDbDataAdapter("Select * From NamesTable", objConnection)
Dim objCommandBuilder As New OleDb.OleDbCommandBuilder(objDataAdapter)
Dim objDataSet As New DataSet()
Then I Fill the DataSet....
objDataSet.Clear()
objDataAdapter.FillSchema(objDataSet, SchemaType.Source, "NamesTable")
objDataAdapter.Fill(objDataSet, "NamesTable")
To find a particular row in the DataSet I do this....
Dim objRow As DataRow
objRow = objDataSet.Tables("NamesTable").Rows.Find(Val("123-45-6789"))
NOW HERE'S MY QUESTION!!! Now that I've found that particular row in the DataSet, How do I find it's "Row Number", (or Row Index... I'm not sure of the terminology"). For example once I found the row that has the key value listed above, how would I reference the very next row????
Seems simple, but I can't figure it out
Thanks for any help!
Steve
-
Oct 8th, 2002, 06:21 AM
#2
Fanatic Member
iRowID = objDataSet.Tables("NamesTable").Rows.Find(Val("123-45-6789")).rowid
-
Oct 8th, 2002, 06:51 AM
#3
Thread Starter
New Member
rowid dosn't work
Hi,
I've tried .rowid, but it doesn't work. Maybe cause I'm talking to an access mdb rather than oracle???
-
Oct 8th, 2002, 07:38 AM
#4
Fanatic Member
How does it not work? As far as I understand it, all DataRows that are members of a DataRows collection (e.g. in a table) have a RowID. I realize the documentation only talks about RowIDs in an Oracle context but run your program in the debugger and set a breakpoint at the line you're searching for the row, and look at the DataRow object in the watch window - for me any DataRow that's in a dataset (I'm not working with Oracle) has a RowID, even with Access (looking at an access sample right now in fact).
-
Oct 8th, 2002, 07:45 AM
#5
Thread Starter
New Member
rowid doesn't work
Hi,
The VB compiler doesn't even let me add the .rowid on the end of the line in design mode. It gives me a syntactical error, (you know, underlines the whole code line).
Is the problem because I only have:
Imports System.Data
Imports System.Data.OleDb
at the top of the program?
Steve
-
Oct 8th, 2002, 07:50 AM
#6
Fanatic Member
Good point, I hadn't actually tried to reference it in code, when I do try I get:
(164): 'System.Data.DataRow.rowID' is not accessible in this context because it is 'Private'.
There's probably a way to sneak around that but I don't know how to do it.
-
Oct 8th, 2002, 07:55 AM
#7
Thread Starter
New Member
.rowid
Hi,
To me, this seems as if it would be a common task people would need to do all the time, (reference a particular row). I'm trying to develop a form WITHOUT databound textboxes, that has a "Lookup" button and some "Next" and "Previous" buttons.
Once I lookup a particular record, I might want to go to the next record in the dataset... How would I do this if I don't know what the rowid is??? (don't know the rowid of the "found" record or of the next record)
With bound controls it's easy... .position = .position + 1 WITHOUT bound controls... who knows!!!??!!!
Steve
-
Oct 8th, 2002, 08:21 AM
#8
Fanatic Member
Well you can refer to records in a table by index number:
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemDataDataRowCollectionClassItemTopic.htm
But taking a DataRow and figuring its index out - I bet there's a way to get at that Private but I don't see how you do it.
-
Oct 8th, 2002, 08:31 AM
#9
Thread Starter
New Member
Hi,
You wrote:
Well you can refer to records in a table by index number:
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemDataDataRowCollectionClassItemTopic.htm
But taking a DataRow and figuring its index out - I bet there's a way to get at that Private but I don't see how you do it.
Refering to a record in a table might just do it for me! I can't seem to get to the link you wrote above, can you tell me how to refer to records in a table by index???
Thanks
-
Oct 8th, 2002, 09:58 AM
#10
Fanatic Member
That's part of the help for Visual Studio, which I hope you installed... It doesn't cut and paste worth a crap, so if you don't have the help for some reason then you can look it up on the MSDN website under the same name (DataRowCollection.Item Property)
-
Oct 8th, 2002, 10:23 AM
#11
Thread Starter
New Member
Ok
Thanks. I'll go look for it.
Steve
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|