sSql="Tag:R,(‘AA\A_1′),’"&UTCBegintime&"’,’"&UTCEndTime&"’,"
sSql=sSql+"’orderbyTimeSTampASC’,’TimEStep="&sVal.Value&",1’"
1.我只想查开始时间A_1变量的一行数据(只要一个数据),请问查询语句怎么写
谢谢,感谢
最佳答案
查询完成后,ors.movefirst
写一次数据就好了
别用for循环
sSql="Tag:R,(”PVArchive\NewTag”),”"&UTCBeginTime&"”,”"&UTCEndTime&"”,"
sSql=sSql+"”orderbyTimestampASC”,”TimeStep="&sVal.Value&",1”"
SetoRs=CreateObject("ADODB.Recordset")
SetoCom=CreateObject("ADODB.Command")
oCom.CommandType=1
SetoCom.ActiveConnection=conn
oCom.CommandText=sSql
”填充数据到Excel中
SetoRs=oCom.ExeCUte
m=oRs.RecordCount
If(m>0)Then
oRs.MoveFirst
i=3
”下面就是填充第一条数据,开始时间的第一个数据
objExcelApp.Worksheets(sheetname).cells(i,1).value=oRs.Fields(0).Value
objExcelApp.Worksheets(sheetname).cells(i,2).value=
GetLocalDate(oRs.Fields(1).Value)
objExcelApp.Worksheets(sheetname).cells(i,3).value=oRs.Fields(2).Value
objExcelApp.Worksheets(sheetname).cells(i,4).value=oRs.Fields(3).Value
objExcelApp.Worksheets(sheetname).cells(i,5).value=oRs.Fields(4).Value
oRs.Close
截取了部分代码,这样应该就是写的第一条,写到EXCEL表格里面
提问者对于答案的评价:
谢谢
专家置评
已阅,最佳答案正确。