与asp.net的SQL连接错误 [英] sql connection error with asp.net

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

问题描述

使用Javascript将数据库sql Server 2005与asp.net连接时出现错误.

我的用户名是= SYSTEM/user2,没有密码,服务器名是= SYSTEM/SQLEXPRESS,Windows身份验证,我的数据库名是Test1,

这是我的代码,它在以下位置显示错误:

conn.open "DSN=Test1;uid=System\user2;password="";"
//code is
<%
            Dim conn
            Dim rs
            strConn = "Driver={SQL Server};Server=127.0.0.1;Database=Test1;Trusted_Conection=Yes;

            Set cnt =Server.CreateObject(ADODB.Connection)

            cnt.ConnectionString=DNS.Test1

            conn.open  DSN=Test1;uid=SYSTEM\user2;password="";

            strSQL = "select * from Test2"

            set rs = cnt.execute(strSQL)
            Do while not rs.eof

            response.Write "Name:" & rs(0)

            rs.movenext

            Loop
  %>


有人可以尝试解决我的问题吗?

解决方案

您的连接字符串中有一个\,这意味着在定义该字符串之前需要使用@.

如果您完全按原样复制了代码,那么它将失败:大概您已经省略了一些引号.无论如何,假设有引号,请尝试以下操作:

conn.open "DSN=Test1;uid=System\user2;password=;"

换句话说,不应使用多余的密码引号(不需要).


相同错误

错误类型:
Microsoft VBScript运行时(0x800A01A8)
所需对象:''
/UI/totalsql.asp,
线=
conn.open"DSN = Test1; uid = System \ user2; password =;"



所需的对象用于/而不是如何解决它,并且在一台机器上的uid是system-user/user2,如何编写它


I am getting error in connecting database sql server 2005 with asp.net, using Javascript.

My user id is= SYSTEM/user2, there is no password, server name is= SYSTEM/SQLEXPRESS, windows authentication and my database name is Test1,

Here is my code and it displays error at:

conn.open "DSN=Test1;uid=System\user2;password="";"
//code is
<%
            Dim conn
            Dim rs
            strConn = "Driver={SQL Server};Server=127.0.0.1;Database=Test1;Trusted_Conection=Yes;

            Set cnt =Server.CreateObject(ADODB.Connection)

            cnt.ConnectionString=DNS.Test1

            conn.open  DSN=Test1;uid=SYSTEM\user2;password="";

            strSQL = "select * from Test2"

            set rs = cnt.execute(strSQL)
            Do while not rs.eof

            response.Write "Name:" & rs(0)

            rs.movenext

            Loop
  %>


Can anybody try to solve my problem?

解决方案

You have a \ in your connection string which means you need to use an @ before you define the string.


If you''ve copied your code exactly as is then it will fail: presumably you''ve omitted some of the quotes. Anyway, assuming that the quotes are there try this:

conn.open "DSN=Test1;uid=System\user2;password=;"

In other words the extra quotes for password (which you don''t need) should not be there.


Same error

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''''
/UI/totalsql.asp,
line =
conn.open "DSN=Test1;uid=System\user2;password=;"



object required is for / than how to resolve it, and also on one machine the uid is system-user/user2, how to write it


这篇关于与asp.net的SQL连接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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