以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  sql语句传入int型参数出错  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=15899)

--  作者:sutingrong
--  发布时间:2012/1/16 17:48:00
--  sql语句传入int型参数出错

求助

我是想将userId传入到sql语句里:where b.userID="+userId,   b.userID的类型是int型的

错误为:输入字符串的格式不正确。。

 

 

代码如下:

Dim userId As Integer
Dim rose As String

userId=7
rose =Vars("user_rose")
If userId<>0 Then
    If rose <>"最高权限" Then
        Tables("入库表_Table1").Fill("SELECT a.HP_BH AS \'序列号\',a.HP_Name as \'设备名称\',b.MX_SQR as \'申请人\',b.MX_SQRPhone as \'联系电话\',b.MX_SQTime as \'入库时间\',b.MX_LY as \'设备来源\' from CK_MX AS b left join CK_HP as a on a.HP_ID = b.HP_ID  where b.userID="+userId, "ck",True)
    Else
        Tables("入库表_Table1").Fill("SELECT a.HP_BH AS \'序列号\',a.HP_Name as \'设备名称\',b.MX_SQR as \'申请人\',b.MX_SQRPhone as \'联系电话\',b.MX_SQTime as \'入库时间\',b.MX_LY as \'设备来源\' from CK_MX AS b left join CK_HP as a on a.HP_ID = b.HP_ID ","ck",True)
    End If
End If

 

 

 


--  作者:狐狸爸爸
--  发布时间:2012/1/16 17:51:00
--  

Tables("入库表_Table1").Fill("SELECT a.HP_BH AS \'序列号\',a.HP_Name as \'设备名称\',b.MX_SQR as \'申请人\',b.MX_SQRPhone as \'联系电话\',b.MX_SQTime as \'入库时间\',b.MX_LY as \'设备来源\' from CK_MX AS b left join CK_HP as a on a.HP_ID = b.HP_ID  where b.userID=" & userId, "ck",True)

 

foxtable中,字符串用&连接起来:

http://www.foxtable.com/help/topics/0221.htm


--  作者:sutingrong
--  发布时间:2012/1/16 18:01:00
--  
原来是这样的啊,呵呵谢谢狐狸爸爸