gpt4 book ai didi

mysql - 如何将列表框的项目存储到 MySQL 表的不同行中

转载 作者:行者123 更新时间:2023-11-29 03:25:44 25 4
gpt4 key购买 nike

我在一个表单中有 2 个列表框。第一个列表框显示数据库表中的行。我使用此代码将行显示为列表框中的项目:

Private Sub Form_load
Dim listbox1 as new Odbc.OdbcDataAdapter("Select columname from table", cn)
Dim dt as new datatable()
listbox.fill(dt)
For a=0 to dt.Rows.Count -1
Listbox.Items.Add(dt.Rows(a). Item(0))
Next
End Sub

显示在这个列表框中的项目被选中并显示在另一个列表框中。我需要有关如何将所选列表框(第二个列表框)上的项目保存到数据库中另一个表的行的帮助

最佳答案

正如您所说,listbox2 是我们的另一个列表框,其中包含来自 listbox1 的项目

For temp As Integer = 0 To ListBox2.SelectedItems.Count - 1
var = ListBox2.SelectedItems.Item(temp)
'Saving item to another table for ex: insert into tab2 values(var);
'Or update tab2 set foo = var where ....;
'..ExecuteQuery()
Next

这里我们从存储在 var 中的 listbox2 中提取数据,并分别准备和执行查询以及将项目保存在数据库中。

关于mysql - 如何将列表框的项目存储到 MySQL 表的不同行中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36501786/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com