Foxtable(狐表)用户栏目专家坐堂 → [求助]SQLReplaceFor更新数据


  共有2301人关注过本帖树形打印复制链接

主题:[求助]SQLReplaceFor更新数据

帅哥哟,离线,有人找我吗?
天一生水
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1137 积分:11230 威望:0 精华:0 注册:2017/9/26 16:30:00
[求助]SQLReplaceFor更新数据  发帖心情 Post By:2020/6/18 21:03:00 [只看该作者]

老师好!

表"日线预测" 通过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)


 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107147 积分:544978 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/6/18 21:13:00 [只看该作者]

还不如直接使用sql

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

 回到顶部