vb中对象变量或是with未设置,在线等啊

来源:百度知道 编辑:UC知道 时间:2024/05/24 09:12:35
Dim rs1 As ADODB.Recordset
Dim cn1 As New ADODB.Connection
Dim ssql1 As String
Private Sub Command1_Click()
rs1.Open "select xm from djb where xm='" & Text1.Text & "'", cn, adOpenForwardOnly, adLockReadOnlystic
Do Until rs.EOF '给listview负值
With ListView1.ListItems.Add(, , "")
.SubItems(1) = Trim(rs!xm)
' .SubItems(2) = Trim(rs!xb)
' .SubItems(3) = Trim(rs!mz)
' .SubItems(4) = Trim(rs!hyzk)
' .SubItems(5) = Trim(rs!csny)
' .SubItems(6) = Trim(rs!szdw)
' .SubItems(7) = Trim(rs!sfzh)
' .SubItems(8) = Trim(rs!cjlb)
' .SubItems(9) = Trim(rs!fdjhr)
' .SubItems(10) = Trim(rs!fzsj)
E

rs1.Open "select xm from djb where xm='" & Text1.Text & "'", cn, adOpenForwardOnly, adLockReadOnlystic
这一行有问题吧,应该是cn1而不是cn

With ListView1.ListItems.Add(, , "")
……
End With

-_-!
是这样写的吧?

With ListView1.ListItems
……
End With

或者

ListView1.ListItems.Add(Trim(rs!xm))