日期:2014-05-17  浏览次数:21099 次

初学ASP,不懂网站怎么连不上数据库,请指教
环境vs2008 sql2000 iis6
网页方面的代码应该都对,是老师给的,数据库根据老师的要求建了一个char数据库,users表
create table Users
(
  Username varchar(50) primary key,
  Password varchar(50) not null
)
网页是关于在线聊天室 这个表用于存注册信息的
全站有
login.aspx login.htm 
global.asax
main.aspx
charcontent.aspx
register.aspx
现在我想试试老师的网站效果,却在注册界面点注册时出问题了:
“/”应用程序中的服务器错误。
--------------------------------------------

用户 '20120501-1040\ASPNET' 登录失败。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

异常详细信息: System.Data.SqlClient.SqlException: 用户 '20120501-1040\ASPNET' 登录失败。

源错误: 


行 44: string ConnectionString = ConfigurationManager.ConnectionStrings["Chat"].ConnectionString;
行 45: SqlConnection conn = new SqlConnection(ConnectionString);
行 46: conn.Open();
行 47: String Sql = "Select * From Users WHERE UserName='" + UserName.Text + "'";
行 48: //SqlCommand对象用来执行数据库命令
 

源文件: c:\Inetpub\wwwroot\Register.aspx.cs 行: 46 

堆栈跟踪: 


[SqlException (0x80131904): 用户 '20120501-1040\ASPNET' 登录失败。]
  System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +821651
  System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186
  System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932
  System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33
  System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +172
  System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +381
  System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181
  System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +173
  System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +357
  System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30
  System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
  System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
  System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +494
  System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
  System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
  System.Data.SqlClient.SqlConnection.Open() +111
  Register.btnRegister_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\Register.aspx.cs:46
  System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
  System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107