CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2002
    Location
    Greece
    Posts
    42

    Run-time error 3800. Problem with table index.

    Hello.
    My program reads records from an mdb database and populates a listview. I want to be able to delete a record from the database, the one which is selected in the listview.
    The database has a table "Main" which has "ID" as the primary key (I keep these values in the Listview.ListItems.Item(ItemIndex).Tag.

    Now I have the following:

    Dim DB As Database
    Dim RS As Recordset

    Set DB = OpenDatabase(App.Path & "\Database\Database.mdb")
    Set RS = DB.OpenRecordset("Main")

    RS.MoveFirst

    RS.Index = ("ID")

    At the above command, I have a run-time error '3800':
    'ID' is not an index in this table.

    Can you tell me what's wrong? From what I understand, it means that "ID" is a wrong name (but it isn't really).
    Visit www.greekroms.net

    Greek translations of roms

  2. #2
    Join Date
    Aug 2003
    Location
    Singapore
    Posts
    34

    Lightbulb May i comment

    May be this helps...
    Code:
    Dim DB As Database
    Dim RS As Recordset
    Dim Items as ListItem
    
    Set DB = OpenDatabase(App.Path & "\Database\Database.mdb")
    'Fields Must Be Selected To Index or Fetch Fields Value
    Set RS = DB.OpenRecordset("SELECT * FROM Main") 
    
    RS.MoveFirst
    
    Do While Not .EOF
    'RS.Index = ("ID") 'What is the purposed?
    Set Items = ListView1.ListItems.Add( , CSTR(RS!ID), RS!FieldName)
    Items.SubItems(1) = RS!FieldName
    '....................
    RS.MoveNext
    Loop
    I May Have Misinterpret U'r Post
    Correct Me If I Am Wrong.........//
    Enjoy Coding............................//


    zak2zak

  3. #3
    Join Date
    Apr 2002
    Location
    Greece
    Posts
    42
    Thanks for answering zak2zak :-)
    I wasn't clear though...
    I don't want to populate my listview, I have already done this.
    I want to delete a record from an access database.
    The name of the table is "Main", the primary key is "ID" and I have it (for example "30").

    My code has the following:

    Dim DB As Database
    Dim RS As Recordset

    Set DB = OpenDatabase(App.Path & "\Database\Database.mdb")
    Set RS = DB.OpenRecordset("Main")

    RS.MoveFirst

    RS.Index = ("ID") 'Here is the error!

    RS.Seek "=", Gamelist.ListItems.Item(ItemIndex).Tag
    RS.Delete
    Visit www.greekroms.net

    Greek translations of roms

  4. #4
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452
    try

    RS.Index = "ID" 'Here is the error!

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

Featured