将ASP与MSSQL SEVER 2005 EXPRESS EDITION连接时出现问题 [英] Having a problem with connecting ASP with MSSQL SEVER 2005 EXPRESS EDITION

查看:66
本文介绍了将ASP与MSSQL SEVER 2005 EXPRESS EDITION连接时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用MSSQL SEVER 2005 EXPRESS EDITION连接ASP时遇到问题,我正在使用javascript编写ASP代码。

看看代码的和平:

var myConnect =" Provider = SQLNCLI; Data Source = .\SQLEXPRESS; Initial Catalog = quiz; User ID = factory1; Password = 123;" ;;


var ConnectObj = Server.CreateObject(" ADODB.Connection");

var RS = Server.CreateObject(" ADODB.Recordset");

var sql = select * from [Quiz.mdf] .dbo.Question" ;;


ConnectObj.Open(myConnect);

RS.Open(sql,ConnectObj ,adOpenForwardOnly,adLockRea dOnly,adCmdText);


IIS抛出错误说:


" Microsoft SQL Native Client(0x80004005)

命名管道提供程序:无法打开与SQL Server的连接[53]。


atConnectObj.Open(myConnect);"

任何团体可以给我一个帮助吗?

Hi, i am having a problem with connecting ASP with MSSQL SEVER 2005 EXPRESS EDITION, i am writing ASP code using javascript.
look at this peace of code:

var myConnect = "Provider=SQLNCLI;Data Source=.\SQLEXPRESS;Initial Catalog=quiz;User ID=factory1;Password = 123;";

var ConnectObj = Server.CreateObject("ADODB.Connection");
var RS = Server.CreateObject("ADODB.Recordset");
var sql="select * from [Quiz.mdf].dbo.Question";

ConnectObj.Open(myConnect);
RS.Open(sql,ConnectObj,adOpenForwardOnly,adLockRea dOnly,adCmdText);

The IIS throws an error says:

"Microsoft SQL Native Client (0x80004005)
Named Pipes Provider: Could not open a connection to SQL Server [53]. "

at "ConnectObj.Open(myConnect);"
Any body can give me a help?

推荐答案

Javascript不是为连接数据库而构建的。


Javascript在用户计算机上本地运行。所以你不能连接到服务器端数据库。


如果你想编写连接到SQL数据库的ASP页面,你需要编写服务器端ASP \vbscript ,或使用coldfusion或其他一些服务器端脚本。


您可以使用JAVA连接到数据库,但这些也是.jsp服务器端文件。这也完全不同于javascript,它通常严格用于客户端的事件处理。
Javascript is not built to connect to databases.

Javascript runs locally on the users machine. So your not going to be able to connect to a server side database.

If you want to write ASP pages that connect to a SQL database you need to write server side ASP\vbscript, or use coldfusion or some other server side scripting.

You can use JAVA to connect to databases but these would be .jsp server side files as well. Also thats totally different from javascript which is usually strictly used for event handling on the client side.


从技术上讲,实际上有技巧。你可以使用javascript来调用服务器端脚本来执行数据库连接。


但是你试图实现代码aboave的方式是不正确的。你上面的代码更接近于vbscript然后是javascript。


无论如何,这里使用JDBC技巧在本地使​​用javascript进行数据库连接是一个有趣的技巧。如果您不熟悉网络编程方法,我可能不建议尝试这个。

Javascript servlet技巧
Technically actually there are "tricks" you can do to use javascript to CALL server side scripts to execute database connections.

But the way you are trying to implement the code aboave is not correct. The code you have above is closer to vbscript then javascript.

Anyway here is an interesting trick in using JDBC trick to use javascript for database connectivity locally. I would probably NOT recommend trying this though if you are unfamiliar with web programming methods

Javascript servlet trick


实际上看起来他在JSP中写的与ASP相同,但用jscript作为语言而不是vbscript。如果是这样,那么是的,你可以用javascript连接。


除此之外,我没有看到什么是错的。我不是一个jscript大师(我不认为很多人)但我认为你的数据库连接是问题,无论如何。数据库连接可能是一个真正的头痛。我总是使用dsn进行连接,设置需要更多工作,但随后会变得更加顺畅。如果您对设置DSN或连接DSN有任何疑问,我很乐意帮助您。


Jared
actually looks like he''s writing in JSP which is the same as ASP, but with jscript as the language rather than vbscript. If that''s the case, then yes you can connect with javascript.

That aside, I don''t see what''s wrong. I''m not a jscript guru (I don''t think many people are) but I think your db connection is the problem, regardless. db connections can be a real headache. I always use a dsn to connect, it takes more work to set up, but then it goes smoother. If you have any questions about setting up a DSN or connecting to it, I would be happy to help you out.

Jared


这篇关于将ASP与MSSQL SEVER 2005 EXPRESS EDITION连接时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆