用JavaScript作为服务器端脚本语言连接数据库问题
<%@LANGUAGE="JAVASCRIPT"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<body>
<%
var conn =Server.CreateObject("ADODB.Connection");
var connectionstring = "PROVIDER=SQLOLEDB;DATA SOURCE=127.0.0.1/MAIL;UID=sa;PWD=zhangalong;DATABASE=SpaceBuilder";
conn.Open(connectionstring);
%>
<%
var trendssection = Request.Form("section");
var trendsname = Request.Form("title");
var trendscontent = Request.Form("content");
Response.Write (trendssection);
Response.Write (trendsname);
Response.Write (trendscontent);
var sql="insert spb_Trends (trendscontent,trendssection,trendsname)values('"+trendscontent+"','"+trendssection+"','"+trendsname+"')";
conn.Execute(sql);
%>
</body>
</html>
一直出现这个错误:
Microsoft OLE DB Provider for SQL Server 错误 '80004005'
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server 不存在或拒绝访问。
/trends/yhg.asp,行 13
但是数据时存在的,连接字符串也对呀,因为用vbscript的
<%
set conn=server.createobject("ADODB.connection")
conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=COMPUTER\MAIL;UID=sa;PWD=zhangalong;DATABASE=SpaceBuilder "
%>
的其他网页都能正常连接数据库呀。