从远程运行时找不到网络路径

时间:2015-11-04 08:20:27

标签: asp.net vb.net sql-server-2008

我上传了我的文件,我把连接字符串放在web配置中这是我的脚本

<connectionStrings>
<add name="it_ConnString"
 connectionString="Server=mssql.genesyssoftware.net;Database=it_db;User 
 ID=mgr;Password=mgr;Trusted_Connection=False;providerName="System.Data.SqlClient"/>
    </connectionStrings>

这是我的完整web.config

<?xml version="1.0"?>
<configuration>

<connectionStrings>
 <add name="it_ConnString" connectionString="Data 
   Source=genesyssoftware.net;Initial Catalog=it_db;User ID=xxxx;
   Password=xxxx" providerName="System.Data.SqlClient" />   
</connectionStrings>
<appSettings>
<add key="CrystalImageCleaner-AutoStart" value="true"/>
<add key="CrystalImageCleaner-Sleep" value="60000"/>
<add key="CrystalImageCleaner-Age" value="120000"/>
<add key="it_ConnString" value="yourConnectionString" />
</appSettings>
<system.web>
    <customErrors mode="Off"/>
    <compilation debug="false" strict="false" explicit="true" 
     targetFramework="4.0">
        <assemblies>
            <add assembly="CrystalDecisions.Web, Version=13.0.2000.0,
             Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, 
             Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
            <add assembly="log4net, Version=1.2.10.0, Culture=neutral, 
             PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.ReportSource, 
             Version=13.0.2000.0, Culture=neutral, 
             PublicKeyToken=692fbea5521e1304"/>
            <add assembly="CrystalDecisions.ReportAppServer.Controllers, 
             Version=13.0.2000.0, Culture=neutral, 
             PublicKeyToken=692FBEA5521E1304"/>
            <add 
              <assembly="CrystalDecisions.ReportAppServer.DataDefModel, 
               Version=13.0.2000.0, Culture=neutral, 
               PublicKeyToken=692FBEA5521E1304"/>
              <add assembly="CrystalDecisions.CrystalReports.Engine, 
               Version=13.0.2000.0, Culture=neutral, 
               PublicKeyToken=692fbea5521e1304"/>
              <add assembly="CrystalDecisions.ReportAppServer.ClientDoc, 
               Version=13.0.2000.0, Culture=neutral, 
               PublicKeyToken=692fbea5521e1304"/>
              <add assembly="Microsoft.ReportViewer.WebForms, 
               Version=10.0.0.0, Culture=neutral, 
               PublicKeyToken=B03F5F7F11D50A3A"/>
              <add assembly="Microsoft.ReportViewer.Common, 
               Version=10.0.0.0, Culture=neutral, 
               PublicKeyToken=B03F5F7F11D50A3A"/>
              <add assembly="Microsoft.Build.Framework, Version=4.0.0.0, 
               Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Management, Version=4.0.0.0, 
             Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Design, Version=4.0.0.0,   
             Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            <add assembly="System.Web.Extensions.Design, 
             Version=4.0.0.0, Culture=neutral, 
             PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Windows.Forms, Version=4.0.0.0, 
             Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        </assemblies>
        <buildProviders>
            <add extension=".rdlc" 
             type="Microsoft.Reporting.RdlBuildProvider, 
             Microsoft.ReportViewer.WebForms, Version=10.0.0.0, 
             Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        </buildProviders>
    </compilation>
    <httpHandlers>
        <add path="CrystalImageHandler.aspx" verb="GET" 
         type="CrystalDecisions.Web.CrystalImageHandler, 
         CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, 
         PublicKeyToken=692fbea5521e1304"/>
        <add path="Reserved.ReportViewerWebControl.axd" verb="*" 
         type="Microsoft.Reporting.WebForms.HttpHandler, 
         Microsoft.ReportViewer.WebForms, Version=10.0.0.0, 
         Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
         validate="false"/>
    </httpHandlers>
 </system.web>
<system.webServer>
    <handlers>
        <add name="CrystalImageHandler.aspx_GET" verb="GET" 
         path="CrystalImageHandler.aspx" 
         type="CrystalDecisions.Web.CrystalImageHandler, 
         CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, 
         PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/>
        <add name="ReportViewerWebControlHandler" 
         preCondition="integratedMode" verb="*" 
         path="Reserved.ReportViewerWebControl.axd" 
         type="Microsoft.Reporting.WebForms.HttpHandler, 
         Microsoft.ReportViewer.WebForms, Version=10.0.0.0, 
         Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    </handlers>
    <validation validateIntegratedModeConfiguration="false"/>
    <directoryBrowse enabled="true"/>
   </system.webServer>
 </configuration>

这是登录语法:

 It_app.Login.cmdLogin_Click(Object sender, EventArgs e) in   
         D:\ASPNET_TRAINING\It_app\It_app\Login.aspx.vb:14

这是我的登录块语法:

Imports System
Imports System.Configuration
Imports System.Data.SqlClient

Public Class Login
     Inherits System.Web.UI.Page
   Dim oConn As String =               
 ConfigurationManager.ConnectionStrings("it_ConnString").ConnectionString
   Dim myConn As New SqlConnection(oConn)
   Dim oCmd As SqlCommand
   Dim oDtr As SqlDataReader
   Dim strSql, cUsr, cPwd As String

  Protected Sub cmdLogin_Click(ByVal sender As Object, ByVal e As 
    EventArgs) Handles cmdLogin.Click
        cUsr = UCase(txtusr.Text)
        cPwd = UCase(txtpwd.Text)
        strSql = "SELECT userlogin,password FROM userlst WHERE userlogin 
           = '" + cUsr + "' AND password = '" + cPwd + "'"
      myConn.Open()
        oCmd = New SqlCommand(strSql, myConn)
        oDtr = oCmd.ExecuteReader

        If Not (oDtr.Read) Then
            Response.Write("User does not exists")
    Else
        Response.Write("Login Success")
        End If
        ' myConn.Close()
End Sub

这是错误完成消息:

Server Error in '/' Application.

找不到网络路径 描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪,以获取有关错误及其在代码中的起源位置的更多信息。

异常详细信息:System.ComponentModel.Win32Exception:找不到网络路径

来源错误:

在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。

堆栈追踪:

[Win32Exception(0x80004005):找不到网络路径]

[SqlException(0x80131904):建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供者:命名管道提供程序,错误:40 - 无法打开与SQL Server的连接)]    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception,Boolean breakConnection,Action 1 wrapCloseInAction) +5352431 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +244 System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +5363103 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +145 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +922 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +307 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) +518 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +278 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +38 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +732 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +85 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1057 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource 1 retry,DbConnectionOptions userOptions,DbConnectionInternal&amp; connection)+78    System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource 1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +196 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource 1 retry,DbConnectionOptions userOptions)+146    System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource 1 retry, DbConnectionOptions userOptions) +16 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource 1 retry)+94    System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)+110    System.Data.SqlClient.SqlConnection.Open()+96    D:\ ASPNET_TRAINING \ It_app \ It_app \ Login.aspx.vb中的It_app.Login.cmdLogin_Click(Object sender,EventArgs e):14    System.Web.UI.WebControls.Button.OnClick(EventArgs e)+9633690    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)+103    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)+10    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,String eventArgument)+13    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)+35    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+1724

但是当我尝试连接数据库时,我收到了该消息错误。

有没有人可以帮助我...

3 个答案:

答案 0 :(得分:0)

出现此问题的原因是远程注册表服务在执行代码的服务器上停止。 转到服务并启动服务

答案 1 :(得分:0)

您是否尝试过使用SQL Management Studio来测试远程SQL Server?如果本地SQLMS无法连接远程sql服务器,则连接字符串也将失败。

答案 2 :(得分:0)

我用mssql更改了托管服务器名称连接字符串。在我的域名之前添加然后重建我的应用然后发布。不知道为什么要工作......