首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

vb中实现数据表中两个数据相加,出现有关问题

2012-03-01 
vb中实现数据表中两个数据相加,出现问题Dim p As IntegerSet cn New ADODB.ConnectionSet rs New ADOD

vb中实现数据表中两个数据相加,出现问题
Dim p As Integer
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open ("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=独占设备;Data Source=PC-20110915FGKA")
sql = "select * from PROCESS where jczhuangtai=0"
rs.Open sql, cn, 1, 3
cn.Execute "update PROCESS set dengdaitime=" & p & " where jinchenghao=(select top 1 jinchenghao from PROCESS where jczhuangtai=0)"
p = rs("dengdaitime") + rs("yunxingtime")
编译不错,结果总是出错,不是显示dengdaitime就是只显示yunxingtime,求改正!

[解决办法]
cn.Execute "update PROCESS set dengdaitime=" & p & " where jinchenghao=(select top 1 jinchenghao from PROCESS where jczhuangtai=0)"
p = rs("dengdaitime") + rs("yunxingtime")

===========
其他且不说, 你先使用P然后才给他赋值. 这未免也太强求人家了吧.

热点排行