ASP服务器发现运行时错误:
错 误 码:0x800A03EC
错误代码:cn.open "Driver={SQL Server}; Server=PC-201008041235\MYSQLSERVER; Database=users; UID=sa; PWD=;"
错误描述:缺少 ';'
反复了一上午没有解决,崩溃了,请大神帮忙,多谢
<HTML>
<BODY bgcolor='000000' text='ffffff'>
<FONT Face='tahoma' color='ffffff'>
<STYLE>
p { font-size=20pt ! important}
font { font-size=20pt ! important}
h1 { font-size=64pt ! important}
</STYLE>
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%>
<%
function trace(str) {
if(Request.form("debug") == "true")
Response.write(str);
}
function Login(cn) {
var username;
var password;
username = Request.form("username");
password = Request.form("password");
var rso = Server.CreateObject("ADODB.Recordset");
var sql = "select * from users where username = '" + username + "' and password = '" + password + "'"; trace("query: " + sql );
rso.open(sql, cn);
if (rso.EOF) {
rso.close();
%>
<FONT Face='tahoma' color='cc0000'>
<H1> <BR>
<CENTER>登陆失败</CENTER>
</H1>
</BODY>
</HTML>
<% Response.end()
return;
}
else {
Session("username") = "" + rso("username");
%>
<FONT Face='tahoma' color='00cc00'>
<H1> <CENTER>登陆成功<BR>
欢迎,<% Response.write(rso("Username")); Response.write( "</BODY></HTML>" ); Response.end()
return;
}
}
function Main() {
var username
var cn = Server.createobject( "ADODB.Connection" )
cn.connectiontimeout = 20
connstr = "Driver={SQL Server}; Server=PC-201008041235\MYSQLSERVER; Database=users; UID=sa; PWD=;"//
cn.open (connstr)
username = new String(Request.form("username"))
if(username.length > 0) {
Login(cn);
}
cn.close();
}
Main();
%>
------解决方案--------------------
服务器端建议使用VBScript比较方便。
js是严格区分大小写的,比如Response.Write(),Request.Form,Server.Createobject,cn.Open等等
------解决方案--------------------
发你修改过的代码看看,是不是有其他没修改到的地方
------解决方案--------------------
少了()
//cn.Open "Driver={SQL Server}; Server=PC-201008041235\MYSQLSERVER; database=USERS; uid=sa; pwd=;"
cn.Open("Driver={SQL Server}; Server=PC-201008041235\MYSQLSERVER; database=USERS; uid=sa; pwd=;");
对象名写错了
function trace(str) {
//if(Request.Worm("debug") == "true")
if(Request.Form("debug") == "true")
------解决方案--------------------
不存在就是那台电脑没安装sqlserver或者配置问题不允许访问了,自己检查
MYSQLSERVER,你是mysql还是mssql,自己搞清楚是什么数据库服务器来先,然后再查找相关驱动字符串怎么写
------解决方案--------------------
cn.Open("Driver={SQL Server}; Server=PC-201008041235\MYSQLSERVER; database=USERS; uid=sa; pwd=;");
检查下驱动,你这列写的是y,不是s,确认示例起名成这个了?