下面是本人编写的一段尝试通过 ADO.NET 连接 SQL Server 2000 数据库的 ASP.NET 代码:
<%@ page language="vb" debug="true" %>
<%@ import Namespace="system.data" %>
<%@ import Namespace="system.data.sqlclient" %>
<script runat="server">
sub page_load()
dim cnn as new sqlconnection("server=localhost;uid=Administrator;pwd=;database=test")
cnn.open()
cnn.close()
end sub
</script>
<html><body>OK!</body></html>
我的 SQL Server 本地服务器的属性中,安全选项卡的设置如下:
授权:SQL Server and Windows/Windows only 选择后者
安全级别:None/Failure/Success/All 选择前者
服务启动帐户:System account/This account 选择前者
SQL Server 的其它设置在安装好后未作任何改动,test 是我自行创建的一个数据库;我的操作系统为 Windows 2000 Advanced Server (SP3),登录用户名为 Administrator,密码为空;.NET Framework 版本为1.0.3705.0。
IE6 编译提示如下错误:
应用程序中的服务器错误:System.Data.SqlClient.SqlException: Login failed for user Administrator. Reason: Not associated with a trusted SQL Server connection.
并指示错误发生在第7行:
cnn.open()
我在安全选项中作多次调整,均未果。请问为何故,这是我在CSDN的第一次提问,望高手不吝赐教。
尝试新建个其他sql用户登录
用户名用sa就行了