程序代码如下:Sub procedure3
Sub procedure3
Dim sPro
Dim sDsn
Dim sSer
Dim sCon
Dim sSql
Dim conn
Dim oRs
Dim oCom
Dim myMinute,mySecond Dim TintData,TfloatData,TboolData,TstringData,Tdate,Ttime
TintData=HMIRuntime.tags("TintData").Read
TfloatData=HMIRuntime.tags("TfloatData").Read
TboolData=HMIRuntime.tags("TboolData").Read
TstringData=HMIRuntime.tags("TstringData").Read
Tdate=HMIRuntime.tags("Tdate").Read
Ttime=HMIRuntime.tags("Ttime").Read
myMinute=HMIRuntime.tags("Tminute1").Read
mySecond=HMIRuntime.tags("Tsecond1").Read
If ((myMinute=0 And mySecond=0) Or (myMinute=10 And mySecond=0) Or (myMinute=20 And mySecond=0) Or (myMinute=30 And mySecond=0) Or (myMinute=40 And mySecond=0) Or (myMinute=50 And mySecond=0)) Then
sCon="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=test;Data Source=GUANLV02\WINCC"sSql="insert into Table6 (Tdate,Ttime,TintData,TfloatData,TboolData,TstringData) values('" & Tdate & "','" & Ttime & "'," & TintData & "," & TfloatData & "," & TboolData & ",'" & TstringData & "')"Set conn=CreateObject("adodb.connection")
conn.connectionstring=sCon
conn.openSet oRs=CreateObject("adodb.recordset")
Set oCom=CreateObject("adodb.command")
oCom.commandType=1
Set oCom.ActiveConnection=conn
oCom.commandText=sSqlSet oRs=oCom.ExecuteSet oCom=Nothing
conn.close
Set oRs=Nothing
Set conn=Nothing
End If
End Sub
执行后数据库中表的结果如下:
请教:
这是为什么呢?是我的SQL插入语句不全吗?还是什么别的原因?
我的要求是插入时间是按降序排列的。该如何做呢?
谢谢各位!
Sub procedure3
Dim sPro
Dim sDsn
Dim sSer
Dim sCon
Dim sSql
Dim conn
Dim oRs
Dim oCom
Dim myMinute,mySecond Dim TintData,TfloatData,TboolData,TstringData,Tdate,Ttime
TintData=HMIRuntime.tags("TintData").Read
TfloatData=HMIRuntime.tags("TfloatData").Read
TboolData=HMIRuntime.tags("TboolData").Read
TstringData=HMIRuntime.tags("TstringData").Read
Tdate=HMIRuntime.tags("Tdate").Read
Ttime=HMIRuntime.tags("Ttime").Read
myMinute=HMIRuntime.tags("Tminute1").Read
mySecond=HMIRuntime.tags("Tsecond1").Read
If ((myMinute=0 And mySecond=0) Or (myMinute=10 And mySecond=0) Or (myMinute=20 And mySecond=0) Or (myMinute=30 And mySecond=0) Or (myMinute=40 And mySecond=0) Or (myMinute=50 And mySecond=0)) Then
sCon="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=test;Data Source=GUANLV02\WINCC"sSql="insert into Table6 (Tdate,Ttime,TintData,TfloatData,TboolData,TstringData) values('" & Tdate & "','" & Ttime & "'," & TintData & "," & TfloatData & "," & TboolData & ",'" & TstringData & "')"Set conn=CreateObject("adodb.connection")
conn.connectionstring=sCon
conn.openSet oRs=CreateObject("adodb.recordset")
Set oCom=CreateObject("adodb.command")
oCom.commandType=1
Set oCom.ActiveConnection=conn
oCom.commandText=sSqlSet oRs=oCom.ExecuteSet oCom=Nothing
conn.close
Set oRs=Nothing
Set conn=Nothing
End If
End Sub
执行后数据库中表的结果如下:
请教:
这是为什么呢?是我的SQL插入语句不全吗?还是什么别的原因?
我的要求是插入时间是按降序排列的。该如何做呢?
谢谢各位!
解决方案 »
- vb如何把文件夹复制到远程机器上呢?文件又如何操作?
- DrawDragRect函数怎么用啊?
- 比眼力啦,看谁的眼睛nb!!!!!!
- 完了,我一个月的心血啊,谁帮帮我啊,文件损坏了。
- 菜啊菜啊菜........
- 关于cursorLocation属性(ADO)
- 100分求救!!帮帮忙了,有关datagrid
- VB40006错误或者40020错误
- 今天问题真多,嘿嘿:如何读取NT/2000的系统日志?
- 请问有没有哪位高手用过ADODB.Recordset的对象CacheSize和MaxRecords?
- VB 报表 The CopyRight String has.........
- vb ini 读取字符串问题 在线等
这样查询时显示就是按指定字段降序排列了
如果不改变数据库的类型该如何做?
如果将时间类型改为datatime 的话,又该如何做?
哪个好做一些?
谢谢