我的程序如下:
str1 = InputBox("请输入编号", "查询")
str2 = "select * from biao where 编号=str1" adrs.CursorLocation = adUseClient
adrs.Open str2, conn, adOpenDynamic, adLockOptimistic ‘总是报这句有错’ Set DataGrid1.DataSource = adrs
说是没有查询对象,可能是没读进数据,可是我的编号也是字符型阿,但总是读不出来,我如果把第二句的str1换成'1'就能查询了,但是我想有用户来输入要查询的字符,可怎么也读不进去,这是怎么回事???? 如果能使str2读的时候为"select * from biao where 编号='(用户输入的值)' "
就可以了,可是怎么能让str1地值加上单引号呢??????
str1 = InputBox("请输入编号", "查询")
str2 = "select * from biao where 编号=str1" adrs.CursorLocation = adUseClient
adrs.Open str2, conn, adOpenDynamic, adLockOptimistic ‘总是报这句有错’ Set DataGrid1.DataSource = adrs
说是没有查询对象,可能是没读进数据,可是我的编号也是字符型阿,但总是读不出来,我如果把第二句的str1换成'1'就能查询了,但是我想有用户来输入要查询的字符,可怎么也读不进去,这是怎么回事???? 如果能使str2读的时候为"select * from biao where 编号='(用户输入的值)' "
就可以了,可是怎么能让str1地值加上单引号呢??????
str2 = "select * from biao where 编号='" & str1 & "'"