Sqlserver2008与经典ASP的连接 [英] Connection of Sqlserver2008 with classic asp

查看:107
本文介绍了Sqlserver2008与经典ASP的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Classic ASP开发应用程序
我的数据库是SQLSErver 2008
我在连接数据库时遇到问题.
这是我以前用来连接的代码.

I am developing an application in Classic ASP
My database is SQLSErver 2008
I am getting a problem in connecting to my database.
Here is the code which i used to connect.

connstring ="server=mymsever;database=mydb;Trusted_Connection=Yes;"
set conntemp = server.createobject("ADODB.Connection")
conntemp.ConnectionString=connstring
conntemp.Open()
Response.Write(conntemp.State)


最后一条语句用于确认我的连接状态是否打开.但是每次我得到0时就表示它已关闭.
在这种情况下该怎么办.如何连接它.


The last statement is for the confirmation that is my connection status open or not. But each time i get 0 as printed which means its closed.
What to do in this case. How to connect it.

推荐答案

您是否正在使用On Error Resume Next.如果是这样,则可能隐藏了conntemp.Open()上发生的异常.如果正在使用它,请确保删除"On Error Resume Next",然后诊断收到的错误.如果您没有收到任何类型的错误,则您的连接字符串可能有误,或者代码中的其他问题导致了您的问题.
Are you using On Error Resume Next. If you are, you may be hiding an exception that is occuring on conntemp.Open(). Ensure that you remove the On Error Resume Next if you are using it and then diagnose the error you receive. If you aren''t receiving an error of any kind, then your connection string may be wrong or there is a problem somewhere else in the code causing you the issue.


感谢Marcus先生.

我试过了,但出现了这个错误.

Thanx Mr. Marcus.

I tried that, and i got this error.

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)<br />
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified



您是否对此错误有任何建议



Do you have any suggestions regarding this error


在这里
OP写道:

我尝试了此操作,但出现了此错误.

用于ODBC驱动程序的Microsoft OLE DB提供程序(0x80004005)
[Microsoft] [ODBC驱动程序管理器]找不到数据源名称,也未指定默认驱动程序

您是否对此错误有任何建议

I tried that, and i got this error.

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Do you have any suggestions regarding this error


这通常发生在以下情况之一:(引自下面的链接)

#您错误地引用了您的连接(例如,拼写了DSN名称,或缺少DSN的字符串组件之一错误);
#您引用了不存在的DSN;
#连接到DSN或无DSN的连接的用户无权访问注册表中存储的信息(请参见KB#306345);
#如果未以该语言设置系统,则使用英文或本地化的驱动程序详细信息作为连接字符串(请参见KB#174655);或者,
#您完全丢失了连接字符串(如果您在会话变量中维护连接字符串,并且会话无效,则可能会发生这种情况;请参阅文章#2157).
80004005错误 [


This usually happens in one of the following scenarios:(Quote taken from below link)

# you referenced your connection incorrectly (e.g. spelled the DSN name, or one of the DSN-less string components wrong);
# you referenced a DSN that doesn''t exist;
# the user connecting to the DSN or DSN-less connection doesn''t have access to the information stored in the registry (see KB #306345);
# you used an English or localized driver detail for your connection string when your system is not set up in that language (see KB #174655); or,
# you are missing the connection string entirely (this can happen if you maintain your connection string in a session variable, and your sessions aren''t working; see Article #2157).
80004005 Errors[^]


这篇关于Sqlserver2008与经典ASP的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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