i=cint(text1.text)
adodc1.recordsource="select * from Table1 where field1>I"
^^^
怎么写阿?
5 个解决方案
#1
dim I as integer
i=cint(text1.text)
adodc1.recordsource="select * from Table1 where field1>" & i
i=cint(text1.text)
adodc1.recordsource="select * from Table1 where field1>" & i
#2
在vb的脚本里用法是:"select * from table1 where field>'"&i&"',不知道vb有无此用法?
你可以在vb中用querydef,它的sql可以写成:querydef1.sql="parameters i integer;select * from ......",使用时对i赋值即可,赋值方法是querydef1![i]=thenum
你可以在vb中用querydef,它的sql可以写成:querydef1.sql="parameters i integer;select * from ......",使用时对i赋值即可,赋值方法是querydef1![i]=thenum
#3
dim I as integer
i=cint(text1.text)
adodc1.recordsource="select * from Table1 where field1" & str(I)
#4
同意以上的说法:
asp(vb script):
"select * from table1 where filed1>"&i
变量可不用cstr之类的函数转换
vb
"select * from table1 where field1>"+str(i)
另,若field1是text型的,应改为
"select * from table1 where field1='"+i+"'" (asp vb script)
"select * from table1 where field1='"+str(i)+"'"
若是日期型的,分界符为“#”象
".....field1=#"+i+"#"等等
asp(vb script):
"select * from table1 where filed1>"&i
变量可不用cstr之类的函数转换
vb
"select * from table1 where field1>"+str(i)
另,若field1是text型的,应改为
"select * from table1 where field1='"+i+"'" (asp vb script)
"select * from table1 where field1='"+str(i)+"'"
若是日期型的,分界符为“#”象
".....field1=#"+i+"#"等等
#5
有几点补充:
1.在引用string变量时要注意其中的"'"号,不然就有麻烦。最好编个函数。如:Public Function CheckForQuote(str As String) As String
Dim i As Integer
Dim s As String
Dim xs As String
If Len(str) < 1 Then
CheckForQuote = str
Else
s = ""
For i = 1 To Len(str)
xs = Mid(str, i, 1)
s = s & IIf(xs = "'", xs & "'", xs)
Next
End If
CheckForQuote = s
End Function
使用:adodc1.RecordSource="select * from table1 where field1 like " & CheckForQuote(s1)
1.在引用string变量时要注意其中的"'"号,不然就有麻烦。最好编个函数。如:Public Function CheckForQuote(str As String) As String
Dim i As Integer
Dim s As String
Dim xs As String
If Len(str) < 1 Then
CheckForQuote = str
Else
s = ""
For i = 1 To Len(str)
xs = Mid(str, i, 1)
s = s & IIf(xs = "'", xs & "'", xs)
Next
End If
CheckForQuote = s
End Function
使用:adodc1.RecordSource="select * from table1 where field1 like " & CheckForQuote(s1)
#1
dim I as integer
i=cint(text1.text)
adodc1.recordsource="select * from Table1 where field1>" & i
i=cint(text1.text)
adodc1.recordsource="select * from Table1 where field1>" & i
#2
在vb的脚本里用法是:"select * from table1 where field>'"&i&"',不知道vb有无此用法?
你可以在vb中用querydef,它的sql可以写成:querydef1.sql="parameters i integer;select * from ......",使用时对i赋值即可,赋值方法是querydef1![i]=thenum
你可以在vb中用querydef,它的sql可以写成:querydef1.sql="parameters i integer;select * from ......",使用时对i赋值即可,赋值方法是querydef1![i]=thenum
#3
dim I as integer
i=cint(text1.text)
adodc1.recordsource="select * from Table1 where field1" & str(I)
#4
同意以上的说法:
asp(vb script):
"select * from table1 where filed1>"&i
变量可不用cstr之类的函数转换
vb
"select * from table1 where field1>"+str(i)
另,若field1是text型的,应改为
"select * from table1 where field1='"+i+"'" (asp vb script)
"select * from table1 where field1='"+str(i)+"'"
若是日期型的,分界符为“#”象
".....field1=#"+i+"#"等等
asp(vb script):
"select * from table1 where filed1>"&i
变量可不用cstr之类的函数转换
vb
"select * from table1 where field1>"+str(i)
另,若field1是text型的,应改为
"select * from table1 where field1='"+i+"'" (asp vb script)
"select * from table1 where field1='"+str(i)+"'"
若是日期型的,分界符为“#”象
".....field1=#"+i+"#"等等
#5
有几点补充:
1.在引用string变量时要注意其中的"'"号,不然就有麻烦。最好编个函数。如:Public Function CheckForQuote(str As String) As String
Dim i As Integer
Dim s As String
Dim xs As String
If Len(str) < 1 Then
CheckForQuote = str
Else
s = ""
For i = 1 To Len(str)
xs = Mid(str, i, 1)
s = s & IIf(xs = "'", xs & "'", xs)
Next
End If
CheckForQuote = s
End Function
使用:adodc1.RecordSource="select * from table1 where field1 like " & CheckForQuote(s1)
1.在引用string变量时要注意其中的"'"号,不然就有麻烦。最好编个函数。如:Public Function CheckForQuote(str As String) As String
Dim i As Integer
Dim s As String
Dim xs As String
If Len(str) < 1 Then
CheckForQuote = str
Else
s = ""
For i = 1 To Len(str)
xs = Mid(str, i, 1)
s = s & IIf(xs = "'", xs & "'", xs)
Next
End If
CheckForQuote = s
End Function
使用:adodc1.RecordSource="select * from table1 where field1 like " & CheckForQuote(s1)