以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]SQLReplaceFor更新数据  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=151251)

--  作者:天一生水
--  发布时间:2020/6/18 21:03:00
--  [求助]SQLReplaceFor更新数据

老师好!

表"日线预测" 通过SQLFind在  表"实际日线"查找数据后赋值。但感到速度比较慢,如果改为SQLReplaceFor更新数据,下列的代码应该怎样修改?

 

Dim  drs As  List(of  DataRow) = DataTables("日线预测").SQLSelect("代码 = \'" & nm & "\'")
For Each  dr As  DataRow In drs
    Dim dr1 As DataRow = Tables("导入数据").DataTable.SQLFind("代码 = \'" & nm & "\'  And 日期 = \'" & dr("日期") & "\'" )
    If dr1 IsNot Nothing Then
        dr("实际日线") = dr1("涨跌幅")
    End If
Next
DataTables("日线预测").SQLUpdate(drs)


--  作者:有点蓝
--  发布时间:2020/6/18 21:13:00
--  
还不如直接使用sql

dim sql as string = "update 导入数据 set 实际日线=日线预测.涨跌幅 from 日线预测 where 日线预测.代码 = 导入数据.代码 and 日线预测.日期 = 导入数据.日期 and 日线预测.代码 = \'" & nm & "\'"