2016-10-14 1 views
0

私は次の形式で接続文字列を使用してSQL Serverデータベースに接続するWindowsフォームアプリケーションを持って実行している作品、失敗しましたデスクトップ上のフォルダ内のexeファイルをクリックすると、データベースに正常に接続できます。バイナリフォルダを共有ドライブにコピーしてダブルクリックすると、プログラムはスローされ、SqlConnection.Open()コマンドでデータベースに接続しようとするとエラーメッセージが表示されます。C#のWinforms SQLAuthenticationは、ローカル

これは彼のために働いていましたが、最近彼は共有への書き込みアクセスを提供するグローバルグループから削除されました。 SQL認証コネクションSTRINGは、それぞれの場合に、正常に機能したときと失敗したときにキャプチャされました。それは同一です。私はそれがOpenConnectionステートメント(ログファイルへの書き込みを試みるのではなく)で正確に失敗していることを知っているので、共有への書き込みアクセス権を持たないのはなぜか分かりません。

1つの質問。接続文字列の "Data Source ="という単語が "Server ="と同じですか?

ConnectionString='Data Source=ServerName;Initial Catalog=DbName;User ID=UserName;Password 

"DataSource"では、コントロールパネルでODBC/OLE DSNを作成すると想定していますか?私はそれは、私はあなたのマシン(ここでアプリケーションが正常に実行された)でDSNを持っていないと思うので、それはServerと同義であると思います。そして、共有場所からDSNが存在するサーバーでも(私はここではストローで把握しています。)アクセス可能ではないでしょう

************** Exception Text ************** 
System.Data.SqlClient.SqlException (0x80131904): The client was unable to establish a connection because of an error during connection initialization process before login. Possible causes include the following: the client tried to connect to an unsupported version of SQL Server; the server was too busy to accept new connections; or there was a resource limitation (insufficient memory or maximum allowed connections) on the server. (provider: Named Pipes Provider, error: 0 - No process is on the other end of the pipe.) ---> System.ComponentModel.Win32Exception (0x80004005): No process is on the other end of the pipe 
    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) 
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) 
    at System.Data.SqlClient.TdsParserStateObject.SNIWritePacket(SNIHandle handle, SNIPacket packet, UInt32& sniError, Boolean canAccumulate, Boolean callerHasConnectionLock) 
    at System.Data.SqlClient.TdsParserStateObject.WriteSni(Boolean canAccumulate) 
    at System.Data.SqlClient.TdsParserStateObject.WritePacket(Byte flushMode, Boolean canAccumulate) 
    at System.Data.SqlClient.TdsParser.SendPreLoginHandshake(Byte[] instanceName, Boolean encrypt) 
    at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) 
    at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) 
    at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) 
    at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) 
    at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) 
    at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) 
    at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) 
    at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) 
    at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) 
    at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) 
    at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) 
    at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) 
    at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) 
    at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) 
    at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) 
    at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) 
    at System.Data.SqlClient.SqlConnection.Open() 

更新

私は何に基づいてIPアドレス

ConnectionString='Server=IPADDRESS;Initial Catalog=DbName;User ID=UserName;Password 

を使用するように接続文字列を変更私 ここで読む:

Name resolution in connection string fails from network share

同じ結果に。

+0

エラーは、名前付きパイプを使用して接続しようとしていることを示しています。それらはリモート側のホストに対してサーバー側で有効になっていますか? –

+0

わかりません。アクセス権のある人から回答を得るまでにはしばらく時間がかかることがあります。しかし、私たちがシェアから走っているのかどうかによってそれはなぜ重要なのでしょうか?私は現在、サーバー名の代わりにIPアドレスを使用するかどうかが重要かどうか疑問に思っています。サーバーの解像度がどうにか失敗する可能性があります。私はちょうどこれを見たが、それをまだ消化していないhttp://stackoverflow.com/questions/15795432/name-resolution-in-connection-string-fails-from-network-share – ChadD

+0

実行可能ファイルへの共有名とディレクトリ特殊文字や疑わしい命名規則がある。また、\\ MySrv \ MyShare \ MyDir \ MyExe.exeまたはH:\ MyShare \ MyDir \ MyExe.exeを実行しています。現在のディレクトリをそのネットワークディレクトリに設定し、その違いがあるかどうかを確認するショートカットを試してみてください。それはあなたに手がかりを与えるかもしれません。 –

答えて

0

私はあなたがあなたの接続文字列が格納されているファイルを追加する必要があるプロジェクトを公開していると思います。あなたの接続文字列によると、プロバイダ名を使用する必要があります。 exeを公開または作成する場合は、プロジェクトにインクルードファイルを選択します。

+0

どちらの場合でも、動作しても機能しない場合、接続文字列をキャプチャして比較しました。コードは、フォルダコピーを実行することによって "展開"されました。ありがとうございます。しかし、答えはターゲット – ChadD

+0

の背後にある理由は、展開時にファイルが見つからない場合にのみ発生します。ローカルコードは常に動作し、プロジェクトにdll、ファイルを追加する必要がありました。 –

+0

ファイルがありません。 – ChadD

関連する問題