Results 1 to 4 of 4

Thread: Very strange database index problem...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    88

    Very strange database index problem...

    Wow - this one has me confused. I have a SQL2000 database that is performing correctly - inserts get inserted, the auto number jumps up one notch accordingly, and all seems well. The problem is, and this is where I'm dumbfounded - is that the index for each of the items, when invoked from a combo box's ItemData property, is the same. No matter what I select I get the number 100081 (this is a valid entry for the primary key in the database, but no matter which entry I invoke from inside the vb6 interface, this number appears).

    I set up a little test with a combo box. The stored procedure is a simple "SELECT ID, Thing FROM tbl_Thing"; ID is the primary unique number; Thing is a 6 digit number:


    Private Sub Command1_Click()

    Dim objrs As New ADODB.Recordset
    Set objrs = New ADODB.Recordset

    objrs.Open "test_thing", g_objConn, adOpenForwardOnly, adLockReadOnly, adCmdStoredProc

    Me.Combo1.Clear

    Do While Not objrs.EOF
    Me.Combo1.AddItem objrs!Thing
    Me.Combo1.ItemData(Me.Combo1.NewIndex) = objrs!ID
    objrs.MoveNext
    Loop

    objrs.Close
    Set objrs = Nothing

    Exit Sub
    End Sub


    and added the following to the Click() event of Me.Combo1:


    Private Sub Combo1_Click()
    Me.Text1.Text = Me.Combo1.ItemData(Me.Combo1.NewIndex)
    End Sub


    This text box, no matter which item I choose from Me.Combo1, shows me 100081.

    I really don't understand this, but I know it must be something in my code since the database is functioning correctly.

    Has anyone had this problem before or know what could cause this?

    Thank you!

    Ed

  2. #2
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Funny, last time I looked, there was a Database forum for these kinds of questions.

    Z.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    88
    Whoop - that's where I meant to put it - I'll repost it...

    Augh!

  4. #4
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    No prob =).

    Z.

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