网页上的字符不能与数据库的字符比较
set rs_t=server.CreateObject("ADODB.recordset")
rs_t.open "SELECT TOP 1 [LOCATION] FROM [PWNT].[dbo].[READER] ",conn,1,3
do while not rs_t.eof
response.Write(rs_t("LOCATION")) '比如得出 小刘
set rs_tt=server.CreateObject("ADODB.recordset")
sql="SELECT [LOCATION] FROM [PWNT].[dbo].[READER] where [LOCATION]='"&rs_t("LOCATION")&"'"
'就算把rs_t("LOCATION")换成任何数据都无法查出数据,换成数字类型的就可以,比如说 123 之类的
rs_tt.open sql,conn,1,3
do while not rs_tt.eof
response.Write(rs_tt("LOCATION")) '无任何输出
rs_tt.movenext
loop
rs_tt.close
set rs_tt=nothing
rs_t.movenext
loop
rs_t.close
set rs_t=nothing 数据库 sql select
[解决办法]
sql="SELECT [LOCATION] FROM [PWNT].[dbo].[READER] where [LOCATION]='"&rs_t("LOCATION")&"'"
修改为
sql="SELECT [LOCATION] FROM [PWNT].[dbo].[READER] where [LOCATION]=N'"&rs_t("LOCATION")&"'"
[解决办法]
nvarchar数据类型是可以进行模糊搜索的.如like,charindex等.