Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ListView VB6和SQL-SERVER,有人能看看我的代码吗?_Sql Server_Listview_Vb6 - Fatal编程技术网

ListView VB6和SQL-SERVER,有人能看看我的代码吗?

ListView VB6和SQL-SERVER,有人能看看我的代码吗?,sql-server,listview,vb6,Sql Server,Listview,Vb6,我发布了一个问题,询问如何用SQL-SERVER中的数据填充vb6中的ListView。所以我能做到。我正在加载运动的名称,并为每个值分配ID。代码如下: lvwExpenditures.ListItems.Clear With lvwExpenditures .FullRowSelect = True .View = lvwReport .LabelEdit = lvwManual .ColumnHeaders.Add , "FldName", "Expense

我发布了一个问题,询问如何用SQL-SERVER中的数据填充vb6中的ListView。所以我能做到。我正在加载运动的名称,并为每个值分配ID。代码如下:

lvwExpenditures.ListItems.Clear
With lvwExpenditures
    .FullRowSelect = True
    .View = lvwReport
    .LabelEdit = lvwManual
    .ColumnHeaders.Add , "FldName", "Expense", 2200
    .ColumnHeaders.Add , "ID", "ID", 0
End With


g_strSQL = "Select FldName, ID, Label, SortOrder from dbo.tblText_References   where fldname ='expenditureitems'"
rs.Open g_strSQL, g_cnDatabase, adOpenStatic
Debug.Print g_strSQL
With rs
  Do While Not .EOF
        Set lvwItem = lvwExpenditures.ListItems.Add(, ,  .Fields("Label").Value)
        lvwItem.SubItems(1) = .Fields("ID").Value 'Populate Date column
     .MoveNext
  Loop
End With
Set rs = Nothing

现在,如果用户愿意,我需要让他们从ListView中选择多个项目。我是用复选框做的,但我试着不用复选框。另外,如果用户选择多个项目,我的Insert语句会是什么样子。我只需要保存与这些ID关联的ID,并将它们关联起来。谢谢

哪一部分不起作用?是否获得已填充的记录集?是的,我在SQL-SERVER中运行查询,并查看是否选择了正确的值。代码卡在子项上。这是我的代码,对不起没有注意到你的名字。我以为你指的是我的密码。
dim g_strSQL as string
g_strSQL = "SELECT ID, Desc FROM refTest_Insurance Where statuscode = 'a'  ORDER BY InsuranceID ASC"
Debug.Print g_strSQL

Dim conn As ADODB.Connection
Dim g_RS As ADODB.Recordset

    ' db_file contains the Access database's file name.
    ' Open a connection.
    Set conn = New ADODB.Connection
    conn.ConnectionString = "Your connection string here"
    conn.Open

    ' Get the records.
    Set g_RS = conn.Execute(g_strSQL, , adCmdText)

    'Set URLs = New Collection
    Do While Not g_RS.EOF
        List1.AddItem g_RS!Desc 
        'URLs.Add CStr(g_RS!Id)

        g_RS.MoveNext
    Loop

    ' Close the recordset and connection.
    g_RS.Close
    conn.Close