2016-08-30 49 views
0

私は自分のサイトをFilezillaで展開しようとしています。私はSQL Server 2012でデータベースを作成し、Visual StudioとSQL Serverを接続しました。ローカルサーバー上で実行するとうまく動作しますが、簡単にサインインしてログアウトできますが、Webに展開すると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..line 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> 
+0

ログインに統合セキュリティが使用されています。データベースはどこにありますか?サイトをどこに展開していますか? –

+0

データソースがWebサーバーで正しく構成されていない可能性がありますか? Plsはそれを示しています... –

+0

私はSQL Serverでデータベースを作成し、Visual Studioでアクセスしました。ウェブ上にデプロイ –

答えて

0

あなたはFilezillaのを使用してウェブサイトを展開したように、FTPフォルダにコピーし、すべてのWebアプリケーションのファイルを、それがないと、データベースはコピーされませんあなたのWebプロジェクトのパスにあなたは

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

のようにフォルダ内のデータベースファイル(.mdfファイル、.LDFなど)を見つけますが、データベースファイルがSQLによって提供されているようまだあなたは、サーバー上にデータベースファイルをコピーし、それらを使用することはできませんサーバーであるため、サーバー(ホスト)上のSQL Serverはデータベースを認識します。

最初の要件は、ホスティングプロバイダがMS SQLデータベースを提供することです。あなたの現在のプロバイダが提供していない場合は、MS SQLデータベースのみを提供するか、MS SQLデータベースを提供する別の提供者を探す必要があります(これらのオプションの財務諸表を作成してください)

ホスティングプロバイダがMS SQLデータベースを使用するには、ホスティングコントロールパネルにログインし、MS SQLオプション(ホスティングプロバイダのコントロールパネルで呼び出すことができるもの)にナビゲートする必要があります。既存のデータベースファイルを添付するか、新しいデータベースを作成してクエリを実行するオプションがあります。(もしあれば、その他のファイル)

データベース

  1. を添付することができた場合は、データベースのMDFとLDFをコピー サーバーへとホスティングコントロールパネルを使用してそれらを添付します( 停止SQL Serverに必要があるかもしれませんホスティングサービスプロバイダは、新しいデータベースを作成することが必要な場合はサービスが

)これを行うには

  1. その後SOのオプションを把握行く(あなたの現在のデータベースのスクリプトを生成するスクリプトを生成その後、タスクを選択し、データベースに(開発マシン上の)ローカルサーバからの右クリックが新しいデータベース
  2. を作成やGoogle)そのオプションが利用可能であるところはどこでもあなたのホスティングコントロールパネルのクエリウィンドウで
  3. コピーこのスクリプトは、()
  4. は、クエリを実行

上記の両方の場合、必要に応じて接続文字列を変更する必要があります(データベース名、作成したユーザー名とパスワードに基づいて)。

+0

それはすばらしいです。私はホストサーバーでデータベースを作成しています。しかし、それは私のmdfまたはldfファイルをインポートするのではなく、CSVファイルをインポートしています。私のホストサーバーが別のマシンにログインしています。スクリプトをそのマヒンに追加して新しいクエリを追加しますが、それは動作していません。 –