<% function OpenDB(dbname) { var connstr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+Server.MapPath(dbname); var conn = Serve...">
当前位置 > 文字教程 > asp教程

如何使用JavaScript来写ASP程序

文章类别:asp | 发表日期:2008-10-5 20:47:35

<%@Language="JavaScript" %>
<%
function OpenDB(dbname)
{
var connstr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+Server.MapPath(dbname);
var conn = Server.CreateObject("ADODB.Connection");
conn.Open(connstr);
return conn;
}
var sResult = new Array();
var oConn = OpenDB("Data/Data.mdb");
//特殊字符:+,%,&,=,?等的传输解决办法.客户端字符是经过escape编码的
//所以服务器端先要经过unescape解码.
//Update:2004-6-1 12:22
var sql = "select SortName From Article_Sort order by OrderID";
var rs = oConn.Execute(sql);
while(!rs.EOF)
{
//unescape解决中文处理的问题.
Response.Write(unescape(rs("SortName").Value + "<BR>"));
rs.MoveNext();
}
%>