|
-
Nov 14th, 2002, 01:23 PM
#1
Thread Starter
Lively Member
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
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
|