我这里有一个代码,用于将记录保存到数据库:
If mstrMaintMode = "ADD" Then
lngIDField = GetNextCustID()
strSPName = "InsertCustomer"
Set objNewListItem = mylistview.ListItems.Add(, , txtname.Text)
PopulateListItem objNewListItem
With objNewListItem
**.SubItems(mlngCUST_ID_IDX) = CStr(lngIDField)**
.EnsureVisible
End With
Set mylistview.SelectedItem = objNewListItem
Set objNewListItem = Nothing
Else
lngIDField = CLng(mylistview.SelectedItem.SubItems(mlngCUST_ID_IDX))
strSPName = "UpdateCustomer"
mylistview.SelectedItem.Text = txtname.Text
PopulateListItem mylistview.SelectedItem
End If
错误是:带星号的行中的属性值无效。我尝试将此代码用于另一个数据库,它可以工作,但对于另一个数据库则不行。我检查了存储过程,它是正确的,表字段也正确,但我仍然收到此错误。我花了 3 小时找到答案,但是我不明白。
最佳答案
当您指定的子项索引超出 ListView 中给定列数的范围时,您突出显示的行将失败并显示“属性值无效”。
由于索引是从 1 开始的,但从第二列开始,索引为 7,因此您至少需要添加 8 列。
关于mysql - vb6 中的属性值无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15242657/