急,在线等待,我的程序为什么在asp.net下不能运行
kongxx 博客专家认证 2003-12-16 04:58:24 我的程序在一个windowapp下可以运行,但是作为一个asp运行的时候老是出错请问是怎么回事
程序代码如下:
string s = "Provider=SQLOLEDB;Data Source=localhost;Integrated Security=SSPI;User ID=kongxx;Initial Catalog=northwind";
OleDbConnection nwindConn = new OleDbConnection(s);
OleDbCommand catCMD = nwindConn.CreateCommand();
catCMD.CommandText = "SELECT CategoryID, CategoryName FROM Categories";
nwindConn.Open();
OleDbDataReader myReader = catCMD.ExecuteReader();
myReader.Close();
nwindConn.Close();
-------------------------------------
报的错误是:
用户 'XX\ASPNET' 登录失败。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.OleDb.OleDbException: 用户 'XX\ASPNET' 登录失败。
源错误:
行 28: OleDbCommand catCMD = nwindConn.CreateCommand();
行 29: catCMD.CommandText = "SELECT CategoryID, CategoryName FROM Categories";
行 30: nwindConn.Open();
行 31:
行 32: OleDbDataReader myReader = catCMD.ExecuteReader();
源文件: c:\inetpub\wwwroot\projectmanager\webform1.aspx.cs 行: 30
堆栈跟踪:
[OleDbException (0x80040e4d): 用户 'XX\ASPNET' 登录失败。]
System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr)
System.Data.OleDb.OleDbConnection.InitializeProvider()
System.Data.OleDb.OleDbConnection.Open()
projectmanager.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\projectmanager\webform1.aspx.cs:30
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731