以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 多个字段 多列值填充 如何有效对应 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=172960) |
-- 作者:cnsjroom -- 发布时间:2021/11/9 9:53:00 -- 多个字段 多列值填充 如何有效对应 当前代码如下: Dim t1 As WinForm.TextBox = e.Form.Controls("TextBox7") Dim tt1 As WinForm.ComboBox = e.Form.Controls("ComboBox1") Dim tt2 As WinForm.ComboBox = e.Form.Controls("ComboBox4") Dim tt3 As WinForm.ComboBox = e.Form.Controls("ComboBox15") Dim Products As List(Of String) Products = DataTables("词典表").GetValues("值","类别=\'球镜\'") Dim Products1 As List(Of String) Products1 = DataTables("词典表").GetValues("值","类别=\'柱镜\'") For Each Product As String In Products Dim dr As Row = Tables("镜片物料").AddNew() dr("初始库存")=0 dr("品牌")=tt1.Text dr("特性")=tt2.Text dr("规格")=tt3.Text dr("球镜")=Product For Each Product1 As String In Products1 dr("柱镜")=Product1 Next dr.Save Next 运行效果如下: 想实现球镜ABC三个规格 柱镜 123 三个规格 生成数据如下: A 1 A 2 A 3 B 1 B 2 B 3 C 1 C 2 C 3 图上数据只有 A 1 B 1 C 1 麻烦老师修正一下 谢谢! |
-- 作者:有点蓝 -- 发布时间:2021/11/9 10:02:00 -- For Each Product As String In Products For Each Product1 As String In Products1 Dim dr As Row = Tables("镜片物料").AddNew() dr("初始库存")=0 dr("品牌")=tt1.Text dr("特性")=tt2.Text dr("规格")=tt3.Text dr("球镜")=Product dr("柱镜")=Product1 Next Next Tables("镜片物料").Save
|
-- 作者:cnsjroom -- 发布时间:2021/11/11 11:25:00 -- 回复:(有点蓝)For Each Product As String In Prod... 老师再次麻烦你哈 楼上的操作 导致写入1600条数据 用时3分钟,有没有更快的写入方式呢? 数据库是ACC 当前代码如下: Dim t1 As WinForm.TextBox = e.Form.Controls("TextBox7") Dim tt1 As WinForm.ComboBox = e.Form.Controls("ComboBox1") Dim tt2 As WinForm.ComboBox = e.Form.Controls("ComboBox4") Dim tt3 As WinForm.ComboBox = e.Form.Controls("ComboBox15") Dim Products As List(Of String) Products = DataTables("词典表").GetValues("值","类别=\'球镜\'") Dim Products1 As List(Of String) Products1 = DataTables("词典表").GetValues("值","类别=\'柱镜\'") For Each Product As String In Products For Each Product1 As String In Products1 Dim dr As Row = Tables("镜片物料").AddNew() dr("初始库存")=0 dr("品牌")=tt1.Text dr("特性")=tt2.Text dr("规格")=tt3.Text dr("球镜")=Product dr("柱镜")=Product1 dr.Save Next Next 采用下述方式 也没有得到明显改善 Dim t1 As WinForm.TextBox = e.Form.Controls("TextBox7") Dim tt1 As WinForm.ComboBox = e.Form.Controls("ComboBox1") Dim tt2 As WinForm.ComboBox = e.Form.Controls("ComboBox4") Dim tt3 As WinForm.ComboBox = e.Form.Controls("ComboBox15") Dim Products As List(Of String) Products = DataTables("词典表").GetValues("值","类别=\'球镜\'") Dim Products1 As List(Of String) Products1 = DataTables("词典表").GetValues("值","类别=\'柱镜\'") For Each Product As String In Products For Each Product1 As String In Products1 Dim cmd As new SQLCommand cmd.C cmd.CommandText = "Insert Into 镜片物料 (初始库存, 品牌, 特性,规格,球镜,柱镜) Values(?,?,?,?,?,?)" cmd.Parameters.Add("@初始库存",0) cmd.Parameters.Add("@品牌",tt1.Text) cmd.Parameters.Add("@特性",tt2.Text) cmd.Parameters.Add("@规格",tt3.Text) cmd.Parameters.Add("@球镜",Product) cmd.Parameters.Add("@柱镜",Product1) cmd.ExecuteNonQuery Next Next MessageBox.Show("结束") [此贴子已经被作者于2021/11/11 11:34:38编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/11/11 11:45:00 -- 最多只能这样 For Each Product As String In Products For Each Product1 As String In Products1 Dim dr As Row = Tables("镜片物料").AddNew() dr("初始库存")=0 dr("品牌")=tt1.Text dr("特性")=tt2.Text dr("规格")=tt3.Text dr("球镜")=Product dr("柱镜")=Product1 去掉,不要一行保存一次,最后保存一次即可dr.Save Next Next Tables("镜片物料").save 可以考虑改为使用SqlServer数据库
|