以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 请教查询时间最大值、最小值的问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=188210) |
-- 作者:HANZHIGANG -- 发布时间:2023/9/7 17:08:00 -- 请教查询时间最大值、最小值的问题 Dim dlg As New OpenFileDialog dlg.Filter = "Excel文件|*.xls;*.xlsx" If dlg.ShowDialog = DialogResult.Ok Then Dim mg As New Merger mg.SourcePath = dlg.FileName mg.Format = "excel" mg.SourceTableName = "运单导入$" mg.DataTableName = "运单导入" mg.Merge() If Tables("运单导入").Rows.Count > 0 Then Dim Result As DialogResult Result = MessageBox.Show("确定导入数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If Result = DialogResult.Yes Then Dim db = HySql.DataBaseFactory.CreateDatabase() db.BulkInsert(DataTables("运单导入").BaseTable, "运单管理") Dim M1 As Date = DataTables("运单导入").SQLCompute("max(操作日期)") Dim M2 As Date = DataTables("运单导入").SQLCompute("min(操作日期)") Dim cmd As New SQLCommand cmd.C cmd.CommandText = "UP DATE {运单管理} SET {运单管理}.到达省份 = {动态管理}.省份 from {运单管理} as {运单管理} inner join {动态管理} as {动态管理} on {运单管理}.[上游到达地] ={动态管理}.[城市] And {运单管理}.[操作员] = \'" & User.Name & "\' And {运单管理}.[操作日期] Between \'" & M2 & "\' And \'" & M1 & "\'" cmd.ExecuteNonQuery() cmd.CommandText = "UP DATE {运单管理} SET {运单管理}.品牌 = {客户管理}.品牌 from {运单管理} as {运单管理} inner join {客户管理} as {客户管理} on {运单管理}.[上游客户] ={客户管理}.[上游客户] and {运单管理}.[商品车] ={客户管理}.[商品车] And {运单管理}.[操作员] = \'" & User.Name & "\' And {运单管理}.[操作日期] Between \'" & M2 & "\' And \'" & M1 & "\'" cmd.ExecuteNonQuery() cmd.CommandText = "UP DATE {运单管理} SET {运单管理}.上游单价 = {上游运价管理}.上游单价 from {运单管理} as {运单管理} inner join {上游运价管理} as {上游运价管理} on {运单管理}.[上游客户] ={上游运价管理}.[上游客户] And {运单管理}.[品牌] ={上游运价管理}.[品牌] And {运单管理}.[上游动态] ={上游运价管理}.[上游动态] And {运单管理}.[计划日期] between {上游运价管理}.[起始日期] And {上游运价管理}.[终止日期] And {运单管理}.[二次] = 0 And {运单管理}.[上游对账] = 0 And {运单管理}.[操作员] = \'" & User.Name & "\' And {运单管理}.[操作日期] Between \'" & M2 & "\' And \'" & M1 & "\'" cmd.ExecuteNonQuery() cmd.CommandText = "UP DATE {运单管理} SET {运单管理}.上游金额 = {运单管理}.台数*{运单管理}.上游单价 from {运单管理} where {运单管理}.[二次] = 0 And {运单管理}.[操作员] = \'" & User.Name & "\' And {运单管理}.[操作日期] Between \'" & M2 & "\' And \'" & M1 & "\'" cmd.ExecuteNonQuery() DataTables("运单管理").LoadFilter = "[操作员] = \'" & user.Name & "\' and [操作日期] Between \'" & M2 & "\' And \'" & M1 & "\'" DataTables("运单管理").Load() End If End If |
-- 作者:HANZHIGANG -- 发布时间:2023/9/7 17:10:00 -- 老师,上面计算操作日期列最大时间和最小时间的方法有误吗,为什么加了这个条件后,数据也不更新了。表也加载不上数据了呢 请老师指导 SQL server数据库
|
-- 作者:有点蓝 -- 发布时间:2023/9/7 17:15:00 -- "运单导入"数据库里有数据吗?SQLCompute查询的是已经保存的数据库。如果是刚导入的数据,是还没有保存的,不要使用SQLCompute,改为Compute |