#2
dhdhzzw2007-09-17 17:51
|
想改成SQL的,但不会改,尤其是蓝字的地方
server.asp 服务器端处理.
<% @Language="JavaScript" %>
<%
function OpenDB(sdbname)
{
/*
*--------------- OpenDB(sdbname) -----------------
* OpenDB(sdbname)
* 功能:打开数据库sdbname,返回conn对象.
* 参数:sdbname,字符串,数据库名称.
* 实例:var conn = OpenDB("database.mdb");
* author:wanghr100(灰豆宝宝.net)
* update:2004-5-12 8:18
*--------------- OpenDB(sdbname) -----------------
*/
var connstr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+Server.MapPath(sdbname);
var conn = Server.CreateObject("ADODB.Connection");
conn.Open(connstr);
return conn;
}
var sResult = "";
var oConn = OpenDB("data.mdb");
//特殊字符:+,%,&,=,?等的传输解决办法.客户端字符是经过escape编码的
//所以服务器端先要经过unescape解码.
//Update:2004-6-1 12:22
var userid = unescape(Request("userid"));
var sql = "select username from users where userid='"+userid+"'";
var rs = oConn.Execute(sql);
if(!rs.EOF)
{
sResult = rs("username").Value;
}
else
{
//加入容错.2004-5-30 10:15
sResult = "Sorry,没有找到..."
}
//escape解决了XMLHTTP。中文处理的问题.
Response.Write(escape(sResult));
%>