试图从一个SQL数据库使用VBScript显示数据 [英] Trying to display data from an SQL database using vbscript

查看:146
本文介绍了试图从一个SQL数据库使用VBScript显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个VBScript内到我的SQL服务器的连接。

I am trying to set up a connection to my SQL server inside of a VBScript.

每当我有没有对,说:有一个问题处理的URL,并与管理员联系。网页错误我的SQL服务器的连接

Whenever I have a connection to my SQL server there is an error on the webpage that says "There was a problem processing the URL" and to contact the administrator.

我知道我的连接字符串是正确的,因为它适用于所有其他网页。

I know my connection string is correct because it works on all the others pages.

下面是code我使用至今建立SQL连接

Here is the code I am using so far to set up the SQL connection

Const SQL_Connection_String = "Provider=sqloledb;SERVER=SQLPROD;DATABASE=MyDataBase;UID=MyUsername;PWD=MyPassword;"
    Set SQLConnection = CreateObject("ADODB.Connection")
    SQLConnection.provider = "ADODB.Connection"
    Set SQLConnectionRecordSet = CreateObject("ADODB.Recordset")

据我所知,这应该是建立在VBScript中的连接的有效方式。我还没有真正找到如何配置这些连接的任何好的文档。

From what I know this should be a valid way of setting up the connection in a VBscript. I have not really found any good documentation on configuring these connections.

我想知道的是:我在正确建立连接,并有一些策略,我可以用它来解决此?意思是我希望能够有一个返回true或false,如果连接成功print语句。我也想以某种方式打印我的读者的内容,看它是否已经从数据库中读取,如果读什么我想它阅读。

What I would like to know is: am I setting up the connection correctly, and Is there some strategy I could use to troubleshoot this? Meaning I'd like to be able to have a print statement that returns true or false if the connection was successful. I would also like to somehow print the contents of my reader to see if it has read from the database and if it read what I wanted it to read.

感谢您的帮助。我使用VBScript和ASP.net是第一次,所以我不知道任何subtlties的。

Thanks for any help. I'm using VBscript and ASP.net for the first time so I don't know any of the subtlties.

推荐答案

SQLConnection.provider = "ADODB.Connection"

肯定是不对的。正如您所指定的连接字符串中的供应商,有一个(小)的机会,删除该行,将会使你的脚本'工作'。

is definitely wrong. As you specify the provider in the connection string, there is a (small) chance that deleting that line, will make your script 'work'.

更新

(1)如果有连接到数据库的问题,使用这个优秀的源上手理论和样品,创建一个空文件(如constr.udl),启动它,并使用GUI来指定/测试连接。离开对话框将保存连接字符串的文件,从那里你可以通过一个体面的把它捡起来(统一code启用)的编辑。

(1) If you have problems connecting to your database, use this excellent source to get started on theory and samples, create an empty file (e.g. constr.udl), start it, and use the GUI to specify/test your connection. Leaving the dialog will save the connection string in the file, from where you can pick it up via a decent (Unicode enabled) editor.

(2)如果你有你的ASP页面上太多的错误,解压(简体)数据库code到一个命令行.vbs脚本;这样你可以专注于一个敌人(与第二个处理的时候你肯定,你的SELECT返回所需的数据)。

(2) If you have too many errors on your ASP page, extract the (simplified) database code to a commandline .vbs script; that way you can focus on one foe (and deal with second one when you are sure, your SELECTs return the desired data).

(3)如果您有与特定的SQL语句/功能/ EX pressions问题,研究文档;在这种情况下,看看自己喜欢的书SQL或效仿谷歌来赞(根据马)。 JOIN可以作为候选了。然后使用(2)从简单的语句开始,继续执行更为复杂的您已经掌握了看似枯燥。
(Table2.Date LIKE'2011'可能工作与否,取决于类型和日期列的内容(而不是日期的保留/关键词?)

(3) If you have problems with specific SQL statements/features/expressions, study the docs; in this case look into your favorite SQL book or follow Google to LIKE (according to the horse). JOIN may be a candidate too. Then use (2) to start from simple statements, proceed to more complex ones after you have mastered the seemingly boring. ("Table2.Date LIKE '2011'" may work or not, depending on the type and content of the Date column (and isn't Date a reserved/key word?)

(虽然德里克必将读取回答另一个他的问题的,其他永世从这里开始,可能会从阅读这个太)。

(While Derek will surely read an answer to another of his question, other poeple starting here will probably profit from reading this too.)

这篇关于试图从一个SQL数据库使用VBScript显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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