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

vb中定义的变量可不可以用在vb中的sql语句中解决办法

2012-01-21 
vb中定义的变量可不可以用在vb中的sql语句中Dim x As IntegerDim y As IntegerDim z As IntegerAdodc11.Re

vb中定义的变量可不可以用在vb中的sql语句中
Dim x As Integer
Dim y As Integer
Dim z As Integer
Adodc11.RecordSource = "select * from PROCESS where jczhuangtai=0"
Adodc11.Refresh
If IsNull(Adodc11.Recordset("number1")) Then
x = 0
Else
x = Adodc11.Recordset("number1")
End If
If IsNull(Adodc11.Recordset("number2")) Then
y = 0
Else
y = Adodc11.Recordset("number2")
End If
If IsNull(Adodc11.Recordset("number3")) Then
z = 0
Else
z = Adodc11.Recordset("number3")
End If
Dim con As New ADODB.Connection
con.Open ("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=独占设备;Data Source=PC-20110915FGKA")
con.Execute "update DCT set zhuangtai=1 where 'dctbiaohao' in(select top x DCT.dctbiaohao from SDT,DCT where SDT.dctbiaohao=DCT.dctbiaohao and SDT.shebeiliexing='input'and DCT.zhuangtai=0)"
con.Execute "update DCT set zhuangtai=1 where 'dctbiaohao' in(select top y DCT.dctbiaohao from SDT,DCT where SDT.dctbiaohao=DCT.dctbiaohao and SDT.shebeiliexing='output'and zhuangtai=0)"
con.Execute "update DCT set zhuangtai=1 where 'dctbiaohao' in(select top z DCT.dctbiaohao from SDT,DCT where SDT.dctbiaohao=DCT.dctbiaohao and SDT.shebeiliexing='store' and zhuangtai=0)"
这里面的top x这个地方出错,可不可以实现?怎么实现?不能实现如何更改?

[解决办法]
con.Execute "update DCT set zhuangtai=1 where 'dctbiaohao' in(select top" & x & " DCT.dctbiaohao from SDT,DC"
[解决办法]

探讨
vb中定义的变量可不可以用在vb中的sql语句中

热点排行