Results 1 to 11 of 11

Thread: This Seems Like It Should Be Simple....

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    12

    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

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    iRowID = objDataSet.Tables("NamesTable").Rows.Find(Val("123-45-6789")).rowid

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    12

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

  4. #4
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    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).

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    12

    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

  6. #6
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    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.

  7. #7

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    12

    .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

  8. #8
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    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.

  9. #9

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    12
    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

  10. #10
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    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)

  11. #11

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    12

    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
  •  



Click Here to Expand Forum to Full Width