ASP 查询语句问题

来源:百度知道 编辑:UC知道 时间:2024/05/26 02:13:00
strSql = "select top"& flagxz &"* from tiku1 where tiku_kecheng like'"& kecheng &"' order by newid()"
用这个语句查询时 错误提示:错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]在关键字 'from' 附近有语法错误。
请高手帮忙看一下 。。在线等。。。FLAGXZ 是数据类型
strSql = "select top"&flagxz& "* from tiku1 where tiku_kecheng like'"& kecheng &"' order by newid()"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open strSql,conn,3,2

按你改的 也不行啊

你的语句:
strSql = "select top"& flagxz &"* from tiku1 where tiku_kecheng like'"& kecheng &"' order by newid()"

改成:
flagxa=cint(flagxa)
strSql = "select top "&flagxz&" * from tiku1 where tiku_kecheng like '%"&kecheng&"%' order by newid()"

'一定要保证变量flagxa为数字.所以在前面要进行数值型转换.
top与后面的行数之间要有空格.数字与* 号之间也要有空格.

strSql = "select top 5 * from tiku1 where tiku_kecheng like '%123%' order by newid()"
你的sql语句注意空格

strSql = "select top " & flagxz & " * from tiku1 where tiku_kecheng like '" & kecheng & "' order by newid()"

注意空格!

strSql = "select top '"&flagxz&"' * from tiku1 where tiku_kecheng like '"&kecheng&"' order by newid()"

最外层的双引号没必要
*与from连写
你先试试

试试:
strSql = "select top '"& flagxz &"