SQLserver数据读取的问题

3.png为什么一样的SQL语句,在sql Management studio 能查出数据,在帆软中查不出来。

账号授权一样,同样适用Navicat也查不出来

FineReport lyh101074750 发布于 2022-5-27 15:44 (编辑于 2022-5-27 16:08)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共5回答
最佳回答
0
lyh101074750Lv3见习互助
发布于2022-5-31 08:13

应该是SQLserver的问题,其他表或者视图可以读,唯独历史表不能读,关键字一类的用大括号就没问题

最佳回答
0
snrtuemcLv8专家互助
发布于2022-5-27 15:45(编辑于 2022-5-27 16:10)

你的数据库字段好多  关键字 ,什么datetime,value,被帆软屏蔽了,最好字段名处理下才可以

==========

image.png

  • lyh101074750 lyh101074750(提问者) 处理了,还是不行
    2022-05-27 16:08 
  • snrtuemc snrtuemc 回复 lyh101074750(提问者) 前面的库名去掉试试,看修改答案
    2022-05-27 16:10 
  • lyh101074750 lyh101074750(提问者) 回复 snrtuemc 还是一样,字段出来了,没有值
    2022-05-27 16:19 
  • snrtuemc snrtuemc 回复 lyh101074750(提问者) 那就看不懂了。。。直接不加where条件,查询全表看看
    2022-05-27 16:21 
  • lyh101074750 lyh101074750(提问者) SELECT * FROM Runtime.dbo.V_History > Msg 7320, Level 16, State 2, Server HIS, Procedure , Line 0 Cannot execute the query \"SELECT Tbl1001.DateTime Col1004,Tbl1001.TagName Col1005,Tbl1001.Value Col1006,Tbl1001.vValue Col1007,Tbl1001.Quality Col1008,Tbl1001.QualityDetail Col1009,Tbl1001.OPCQuality Col1010,Tbl1001.wwTagKey Col1011,Tbl1001.wwRowCount Col1012,Tbl1001.wwResolution Col1013,Tbl1001.wwEdgeDetection Col1014,Tbl1001.wwRetrievalMode Col1015,Tbl1001.wwTimeDeadband Col1016,Tbl1001.wwValueDeadband Col1017,Tbl1001.wwTimeZone Col1018,Tbl1001.wwVersion Col1019,Tbl1001.wwCycleCount Col1020,Tbl1001.wwTimeStampRule Col1021,Tbl1001.wwInterpolationType Col1022,Tbl1001.wwQualityRule Col1023,Tbl1001.wwStateCalc Col1024,Tbl1001.StateTime Col1025,Tbl1001.PercentGood Col1026,Tbl1001.wwParameters Col1027,Tbl1001.StartDateTime Col1028,Tbl1001.SourceTag Col1029,Tbl1001.SourceServer Col1030,Tbl1001.wwFilter Col1031,Tbl1001.wwValueSelector Col1032,Tbl1001.wwMaxStates Col1003 FROM Runtime.dbo.History Tbl1001\" against OLE DB provider \"INSQL\" for linked server \"INSQL\". > OLE DB provider \"INSQL\" for linked server \"INSQL\" returned message \"History queries must contain at least one valid tagname\". > [42000] [Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot execute the query \"SELECT Tbl1001.DateTime Col1004,Tbl1001.TagName Col1005,Tbl1001.Value Col1006,Tbl1001.vValue Col1007,Tbl1001.Quality Col1008,Tbl1001.QualityDetail Col1009,Tbl1001.OPCQuality Col1010,Tbl1001.wwTagKey Col1011,Tbl1001.wwRowCount Col1012,Tbl1001.wwResolution Col1013,Tbl1001.wwEdgeDetection Col1014,Tbl1001.wwRetrievalMode Col1015,Tbl1001.wwTimeDeadband Col1016,Tbl1001.wwValueDeadband Col1017,Tbl1001.wwTimeZone Col1018,Tbl1001.wwVersion Col1019,Tbl1001.wwCycleCount Col1020,Tbl1001.wwTimeStampRule Col1021,Tbl1001.wwInterpolationType Col1022,Tbl1001.wwQualityRule Col1023,Tbl1001.wwStateCalc Col1024,Tbl1001.StateTime Col1025,Tbl1001.PercentGood Col1026,Tbl1001.wwParameters Col1027,Tbl1001.StartDateTime Col1028,Tbl1001.SourceTag Col1029,Tbl1001.SourceServer Col1030,Tbl1001.wwFilter Col1031,Tbl1001.wwValueSelector Col1032,Tbl1001.wwMaxStates Col1003 FROM Runtime.dbo.History Tbl1001\" against OLE DB provider \"INSQL\" for linked server \"INSQL\". (7320) [01000] [Microsoft][SQL Server Native Client 11.0][SQL Server]OLE DB provider \"INSQL\" for linked server \"INSQL\" returned message \"History queries must contain at least one valid tagname\". (7412)
    2022-05-27 16:31 
最佳回答
0
Z4u3z1Lv6专家互助
发布于2022-5-27 15:46(编辑于 2022-5-27 16:15)

image.png

防注入

image.png

  • lyh101074750 lyh101074750(提问者) 还是不行,我把关键字都弄了
    2022-05-27 16:06 
  • Z4u3z1 Z4u3z1 回复 lyh101074750(提问者) 看截图开了防注入就直接报错了,而不是不出数据
    2022-05-27 16:15 
  • lyh101074750 lyh101074750(提问者) 数据库没有报警,字段都选出来了,值没有出来
    2022-05-27 16:20 
  • Z4u3z1 Z4u3z1 回复 lyh101074750(提问者) 你只在select 后面加了中括号,where 后面没加啊
    2022-05-27 16:26 
  • lyh101074750 lyh101074750(提问者) 回复 Z4u3z1 select * from runtime.dbo.v_history where Tagname= XXXX,在studio能查,在帆软查不出。但是字段都显示了,字段类型是?
    2022-05-27 16:38 
最佳回答
0
omydaiLv5见习互助
发布于2022-5-27 16:15(编辑于 2022-5-27 16:17)

大概率是你表名不行,把.去掉,你看表名都灰色了

最佳回答
0
帆软用户6WJN5HM5hALv0见习互助
发布于2023-6-8 09:30

你好,问题解决了吗,我现在也遇到了类似问题

  • 3关注人数
  • 711浏览人数
  • 最后回答于:2023-6-8 09:30
    请选择关闭问题的原因
    确定 取消
    返回顶部