找不到网络路径错误消息

时间:2016-08-30 05:44:39

标签: c# html asp.net

我正在尝试通过Filezilla部署我的网站。我在sql server 2012中创建了数据库,并将我的visual studio与sql server连接起来。当我在本地服务器上运行它时工作正常,我可以轻松登录并注销,但当我在网络上部署它时,它会在con.open()行显示此错误。请帮助。

描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

  

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

public partial class signinregistration : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click1(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(@"Data Source=ISL-4;Initial Catalog=Cruisedb;Integrated Security=True");
        con.Open();
        DataTable dt = new DataTable();
        SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM [Login] WHERE Email = @email AND Password = @password", con);
        using (con)
        {
            sda.SelectCommand.Parameters.AddWithValue("@email", this.textboxemail.Text);
            sda.SelectCommand.Parameters.AddWithValue("@password", this.textboxpassword.Text);

            sda.Fill(dt);

            if (dt.Rows.Count == 0)
            {
                textboxemail.Text = "";
                textboxpassword.Text = "";
                Label3.Visible = true;

                return;
            }

            string txt = textboxemail.Text;
            Session["Email"] = txt;
            Response.Redirect("index.aspx");
        }
    }
}

源文件:第27行......第27行是con.open()。

堆栈追踪:

[Win32Exception (0x80004005): The network path was not found]

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
+5341995
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +546    
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +5353703    
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) +892
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +311
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) +646    
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& 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    
signinregistration.Button1_Click1(Object sender, EventArgs e) in \\smb-whst-www02\whst_www02$\ff8b1b\user\fareshoppers.co.uk\web\signinregistration.aspx.cs:27 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9628462
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
  
@MachineLearning
<?xml version="1.0"?>
    <configuration> 
        <connectionStrings> 
           <add name="ConnectionString" connectionString="Data Source=ISL-4;Initial Catalog=Cruisedb;Integrated Security=True" providerName="System.Data.SqlClient"/> 
       </connectionStrings> 
      <system.web> 
          <compilation debug="true" targetFramework="4.0">
          <assemblies>
              <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
          </assemblies>
     </compilation> 
    <customErrors mode="Off"/> 
</system.web> 
</configuration>

1 个答案:

答案 0 :(得分:0)

在使用FileZilla部署网站时,它会将您的所有Web应用程序文件复制到ftp文件夹,但不会复制您的数据库,因为它不在您的Web项目路径中。您将在

这样的文件夹中找到您的数据库文件(.mdf,.ldf等)

C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data

但是您仍然无法将数据库文件复制到服务器上并使用它们,因为SQL Server会提供数据库文件,因此您的服务器(主机)上的SQL Server应该知道数据库。

首先要求您的托管服务提供商应为您提供MS SQL数据库。如果您当前的提供商没有提供,那么您应该寻找一个单独的提供,他可以只为您提供MS SQL数据库或托管MS SQL数据库(您可以计算出这些选项的财务)

当您的托管服务提供商为您提供MS SQL数据库时,您必须登录您的主机控制面板并导航到MS SQL选项(无论您可以在托管服务提供商的控制面板中调用)。在那里,您可以选择附加现有数据库文件或创建新数据库并运行查询。

如果您可以附加数据库

  1. 将您的数据库的mdf和ldf(以及其他文件,如果有的话)复制到 服务器并使用主机控制面板附加它们(您可能需要 停止SQL Server服务来执行此操作)
  2. 如果您的托管服务提供商要求您创建新数据库

    1. 然后在那里创建一个新数据库
    2. 从本地服务器(在开发计算机上)右键单击数据库,选择 Tasks 然后 Generate Script 以生成当前数据库的脚本(转到图SO或Google上的选项)
    3. 将此脚本复制到主机控制面板的查询窗口中(只要该选项可用)
    4. 运行查询
    5. 对于上述两种情况,您将/可能必须根据需要更改连接字符串(基于数据库名称,您创建的用户名及其密码)

      希望有所帮助。