我在用OLEDB方式连接SQL Server时, 用到连接字: "provider=SQLOLEDB.1;data source=localhost;initial catalog=WroxBooks; Trusted_Connection=yes; User ID=sa;Password=;"
调用后一直无法正常连接。
ASP.NET错误描述:
* Error while accessing data.
用户 'CXY\ASPNET' 登录失败。
ASP错误描述:
Microsoft OLE DB Provider for SQL Server (0x80040E4D)
用户 'CXY\IUSR_CXY' 登录失败。
已确信所连接的数据源,帐号和口令都是正确的,根据出错描述,怎么连接会用
CXY\ASPNET或CXY\IUSR_CXY登录?(我已明确指定User ID=sa;Password=;),经过多
次试验,最后将连接字中的Trusted_Connection=yes;删除,连接成功!
如果明白SQL Server登录验证的原理, 就可以知道Trusted Connection的含义。
在SQL Server Architecture(SQL Server架构)登录篇中有关于Authenticating Logins(登录验证)的讲述, 摘录如下:
......
SQL Server 2000 uses two types of authentication: Windows Authentication
and SQL Server Authentication.
......
When using Windows Authentication, you do not have to specify a login ID
or password when you connect to SQL Server 2000. Your access to SQL
Server 2000 is controlled by your Windows NT or Windows 2000 account or
group, which is authenticated when you log on to the Windows operating
system on the client.
When you connect, the SQL Server 2000 client software requests a Windows
trusted connection to SQL Server 2000. Windows does not open a trusted
connection unless the client has logged on successfully using a valid
Windows account. The properties of a trusted connection include the
Windows NT and Windows 2000 group and user accounts of the client that
opened the connection. SQL Server 2000 gets the user account information
from the trusted connection properties and matches them against the
Windows accounts defined as valid SQL Server 2000 logins. If SQL Server
2000 finds a match, it accepts the connection. When you connect to SQL
Server 2000 using Windows 2000 Authentication, your identification is
your Windows NT or Windows 2000 group or user account.
SQL Server 2000采用两种不同的验证方式:Windows验证和SQL Server 2000验证
用Windows验证连接时,不必指定一个用户ID及口令,连接验证使用Windows NT或2000的组帐号(group account)。
要知道:SQL Server 2000 在连接验证之前,用户先用Windows NT或2000的组帐号在客户端成功登录至SQL Server 2000服务器,方能建立一个信任连接(Trusted connection),SQL Server从信任连接属性中获取用户的帐号信息,将其与Windows已定义的帐号信息匹配和分析,如果正确就连接成功,并将此Windows帐号作为连接至SQL Server 2000的用户ID。
上文中的连接字中包含有:Trusted_Connection=yes;
这就意味着连接将采用信任连接方式,但由于连接前没有用Windows组帐号(在ASP环境中是访问IIS服务帐号IUSR_计算机名,在ASP.NET环境中帐号是ASPNET)登录至SQL Server 2000服务器, 也就是说没有建立一个信任连接(Trusted connection),当然,SQL Server 2000连接也不能够成功。
将Trusted_Connection=yes;删除或改为Trusted_Connection=no;
这将不采用信任连接方式(也即不采用Windows验证方式),而改由SQL Server 2000验证方式,即在连接字中指定:User ID=user name;Password=user password;
SQL Server 2000会将此用户ID和口令进行验证连接,而与Windows帐号无关。
关于SQL Server 2000上述两种验证方式的设置(连接验证采用Windows和SQL Server验证,还是仅采用Windows验证),可以启动SQL Server 2000企业管理器,然后在安全性配置中设置。
分享到:
相关推荐
对于win2000,我配置了两个sql的ODBC连接 一个名为:test,使用sa登陆,无密码 一个名为:testnt,使用windows身份验证 [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources] "test"="SQL Server...
连接字符串中常用的声明有: 服务器声明 Data Source、Server和Addr等。 数据库声明 Initial Catalog和DataBase等。 集成Windows账号的安全性声明 Integrated Security和Trusted_Connection等。 使用数据库账号的...
本程序使用VS2010和SQL2008进行开发,在低...Trusted_Connection = true"; 即,将此句中 data source 的数据改成本地的数据库名称 m_connection = new SqlConnection(connectionString); m_connection.Open();
精美的简易论坛源码 1.如何运行调试网站: 1) 新建一个空的SQL SERVER ...Trusted_Connection=no;database=forum" 5) 如果你装了VS2005,则可以直接双击Forum.sln打开网站源代码 6) 运行网站,default.aspx为起始页
Trusted_Connection=yes;') userprof_df = pd.read_sql("SELECT up.*, uc.Rcuisine as cuisine FROM users.userProfile as up join users.userCuisine as uc on up.userID = uc.userID", conn) # userr
FSharp.Data.SqlClient-Microsoft SQL Server的类型提供程序通过 ,该库以类型安全的方式向F#代码公开SQL Server数据库对象。 您可以在Visual Studio附带的F#Interactive中引用它#r " nuget: FSharp.Data....
用SQLserver数据库时的产品安装指南 自动安装: 源码版安装之前,您需要重新生成解决方案(管理员身份打开项目),安装版不需要重新生成解决方案 1.使用 FTP 软件登录您的服务器,建立或者选择一个目录,将...
更改以下连接字符串:“ DefaultConnection”:“ Server = desktop-s534fuv; Database = MovieHubTry; Trusted_Connection = True;” “ DefaultConnection”:“服务器=(您的服务器名称);数据库=(数据库名称)...
石斑鱼 规范程序方法主题要在本地运行它,您需要.net5 sdk 或仅将Visual Studio ...Trusted_Connection=True;Integrated Security=SSPI;MultipleActiveResultSets=true" 并设置Server={your local server}就是这样。
2、开发环境为Visual Studio 2010,数据库为SQL Server 2005,数据库文件在DB_51aspx 文件夹中,使用.net 2.0开发。 数据库连接需要修改数据库连接字符串 SpringResource/spring_bean_dao.xml:Spring配置文件下的...
最新版本下载地址: ... 这是一个简单的论坛,主要功能: ... ... 用户管理、网站美工暂时还没有做...Trusted_Connection=no"/> 这个数据库链接字符串。 2)页面地址是经过重写过的,URL地址重写配置信息放在Urls.xml文件中。
请尝试以下操作:将连接字符串设置为标准的连接字符串:Server = COMPUTER_NAME \ INSTANCE_NAME; 数据库=数据库; Trusted_Connection = True;并将上面的占位符替换为:COMPUTER_NAME-运行SQL Server或SQL Server的...
string str = "server=.\\SQLEXPRESS;database=student;Trusted_Connection=true;"; SqlConnection con = new SqlConnection(str); con.Open(); str = "select count(*) from userTable"; SqlCommand cmd = new...
欧洲汽车 欧洲汽车是用于汽车广告的ASP .NET Core Blazor服务器端应用程序。... 广告本身包括有关任何汽车的最重要信息,例如...Trusted_Connection=True;MultipleActiveResultSets=true" }, "Logging": { "LogLevel
ApiBilling 在.net Core和SQL Server中开发的Billing Web Api 记住要在Startup.cs中更改数据库连接,以便能够有效地工作。 var connection = @“ Server =” YourServer“;数据库= Billing2; Trusted_Connection = ...
<sessionState nmode=SQLServer sqlConnectionString source=127.0.0.1;Trusted_Connection yes cookieless=false timeout> 保存session到windows进程,要使用这种方法,需要打开aspnet_state.exe服务,通过此方法,...
五、下列ASP.NET语句( )正确地创建了一个与SQL Server数据库的连接。 A.SqlConnection con1 = new Connection(“Data Source = localhost; Trusted_Connection =Yes; Initial Catalog = myDB”); B.SqlConnection ...
海滨之屋 安装包Microsoft.EntityFrameworkCore Microsoft.EntityFrameworkCore.Tools Microsoft.EntityFrameworkCore.In... Trusted_Connection = True;” Microsoft.EntityFrameworkCore.SqlServer -OutputDir模型
RazvojSoftveraII Vježbeiz predmeta Razvoj softvera 2(2021) Docker SQL映像 docker pull mcr.microsoft.com/mssql/server:2017-latest docker run -e 'ACCEPT_EULA=Y' -e 'SA_...Trusted_Connection=True
Trusted_Connection=SSPI"; SqlConnection Conn = new SqlConnection(str); Conn.Open(); string sqlstring = "select * from [游客信息管理] where username= '" + textBox1.Text + "' and userpass= '" + textBox2...