我有通过text1 text2 输入两个编号(字符型)如:Y12345,Y12346
想通过这些编号得到他们的值 如Y12345的值为12345 , Y12346的值为12346
我的语句这样写的
update pand1 set beizhu= '* 'from pand1 where 编号 between VAL( " & Trim(Text2.Text) & ") and val (" & Trim(Text3.Text) & ")
但报错为:VAL是不可识别的函数,请问我该怎么写这条SQL语句
想通过这些编号得到他们的值 如Y12345的值为12345 , Y12346的值为12346
我的语句这样写的
update pand1 set beizhu= '* 'from pand1 where 编号 between VAL( " & Trim(Text2.Text) & ") and val (" & Trim(Text3.Text) & ")
但报错为:VAL是不可识别的函数,请问我该怎么写这条SQL语句
set beizhu = '*'
from pand1
where 编号 between replace(你的变量值,'Y','') ......
我的系统是VB做的!
set beizhu= '* '
from pand1
where 编号 between cast(replace(text1.text,'Y','') as int) and cast(replace(text2.text,'Y','') as int)友情提示:这里没有判断到底text1.text表示的数值与text2.text表示数值的大小,应该在前台程序中加以判断,保证送入SQL执行的数据满足正常要求.
在VB中的写法为:dim strSQL as string
strSQL=""
strSQL=strSQL + "update pand1" + vbCR
strSQL=strSQL + " set beizhu= '* ' " + vbCR
strSQL=strSQL + "from pand1 " + vbCR
strSQL=strSQL + "where 编号 between cast(replace(" & text1.text & ",'Y','') as int) and cast(replace(" & text2.text & ",'Y','') as int)"
楼主你把这个变量strSQL送给ADO就可以达到你要的效果了,但是一定要检查text1.text表示的数值与text2.text表示数值的大小,以免出现异常中断程序.
我现在是这样做的
我现在用VB这样做
Dim n As Integer
Dim m As Integer
'Adodc1.CommandType = adCmdText
'Adodc1.RecordSource = "select * from pand1 where pandiandanhao = '" & Trim(Text2.Text) & "'"
'Adodc1.Refresh
'n = Val(Adodc1.Recordset.Fields("id"))'Adodc1.CommandType = adCmdText
'Adodc1.RecordSource = "select * from pand1 where pandiandanhao = '" & Trim(Text3.Text) & "'"
'Adodc1.Refresh
'm = Val(Adodc1.Recordset.Fields("id"))
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from pand1 where pandiandanhao between cast(replace( " & Trim(Text2.Text) & " ,'Y','') as int) and cast(replace(" & Trim(Text3.Text) & " ,'Y','') as int) and beizhu = ' T '"
Adodc1.Refresh
但还有问题,不知道该怎么处理,希望大家帮忙看还有没有别的方法
pandiandanhao 就是我说的编号,id是另外一列,只数据库自动编号的,为int型,但还是有问题