我需要将字段中的 SQl 数据添加到 ListView 框中。这就是我目前所拥有的。我只是不确定如何将数据作为列表添加到列表视图框中。
Option Explicit
Private Sub CommandButton1_Click()
Dim ConnectionObj As ADODB.Connection
Set ConnectionObj = New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim cmd As ADODB.Command
Dim sqlstr As String
ConnectionObj.CursorLocation = adUSeClient
ConnectionObj.Open "PROVIDER=MSDASQL;dsn=SVR-TESTSQL-01_SQL2008R2;DATABASE=WebVanilla;uid=WebUser;pwd=1209sawedxz1209;"
sqlstr = "select top 10 * from DeFactoUser.F_GL_Events"
rs.Open sqlstr, ConnectionObj, adOpenKeyset
MsgBox "Connected" & rs.RecordCount
If rs.RecordCount > 0 Then
rs.MoveFirst
Do While Not rs.EOF
'Add to list view box command Data = rs.Fields(0)
rs.MoveNext
Loop
End If