错误显示:
Server Error in '/myoa/Webs' Application.
--------------------------------------------------------------------------------SQL Server does not exist or access denied. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.Source Error: 
Line 37:  myCommand.Parameters.Add(parameterReason);
Line 38: 
Line 39:  myConnection.Open();
Line 40:  myCommand.ExecuteNonQuery();
Line 41:  myConnection.Close();
 Source File: C:\Inetpub\wwwroot\myoa\DA\EmpDB.cs    Line: 39 Stack Trace: 
[SqlException: SQL Server does not exist or access denied.]
   System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +472
   System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
   System.Data.SqlClient.SqlConnection.Open() +384
   myoa.DA.EmpDB.Login(String loginid, String password) in C:\Inetpub\wwwroot\myoa\DA\EmpDB.cs:39
   Webs.login1.ok_Click(Object sender, ImageClickEventArgs e) in c:\inetpub\wwwroot\myoa\Webs\login.aspx.cs:68
   System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +109
   System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +69
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1277我用的系统是windows sp2 

解决方案 »

  1.   

    连接字符串是什么?用的是Sql身份验证么?
      

  2.   

    如果是使用SSPI方式连接数据库,则
    在SQL Server中,把aspnet用户添加上,没设置其权限
      

  3.   

    是windows 2003的话就要把给Network Service访问SQL的权限
      

  4.   

    如果是本机数据库,不能写localhost要写(local)
      

  5.   

    <appSettings>
    <add key="ConnectionString" value="server=localhost;database=myoa;User ID=sa;password="/>
    </appSettings>
    我是这样写的!!!
      

  6.   

    数据库连接字符串大全,请参见:http://www.connectionstrings.com/
      

  7.   

    <appSettings>
    <add key="ConnectionString" value="server=(local);database=myoa;User ID=sa;password="/>
    </appSettings>