2011-12-26 11 views
1

データベースにアクセスするWebサービスを作成しました。データベースとウェブサービス(すなわち、SQLサーバとIIS)は同じマシン上にある。データベースにアクセスするWebサービスに関する問題

問題は、クライアントにアクセスするWebサービスにアクセスしたときに、すべて正常に動作することです。

しかし、他のパソコンからアクセスすると、データベースエラーが発生します。

サーバーへのアクセス中にリモートからWebサービスにアクセスしているときに、接続が開かれないときに、同じ接続文字列が正常に機能します。

助けてください。

[編集]

私は、サーバー上でアクセスすると、私はこのように私の要件ごとにログを取得:

のConnectionString =サーバー=ローカルホストの\ INSTANCENAME;データベース= DBNAME; UID = UID; Pwd = pwd;

と私はリモートでアクセスするとき、私はこのようなログを取得:

のConnectionString =サーバー=ローカルホストの\ INSTANCENAME;データベース= DBNAME; UID = UID; PWD = PWDを。あなたは間違った情報を提供していることを

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) 
    at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) 
    at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) 
    at CMACLBilling.AuthenticationService.Service1.GetUser(String userName) 
    at CMACLBilling.BusinessControllers.UserBusinessController.Authenticate(String userName, String password, Int32& errorCode) 
    at CMACLBilling.LoginWindow.btnLogin_Click(Object sender, RoutedEventArgs e) 
    at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) 
    at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) 
    at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) 
    at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e) 
    at System.Windows.Controls.Primitives.ButtonBase.OnClick() 
    at System.Windows.Controls.Button.OnClick() 
    at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) 
    at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e) 
    at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) 
    at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) 
    at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) 
    at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) 
    at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent) 
    at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e) 
    at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) 
    at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) 
    at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) 
    at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) 
    at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) 
    at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) 
    at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) 
    at System.Windows.Input.InputManager.ProcessStagingArea() 
    at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) 
    at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) 
    at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) 
    at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
    at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
    at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
    at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) 
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) 
    at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) 
+0

をあなたはそれが問題か示すコードを引き起こすかもしれないと思う場合、問題の接続文字列を指定します –

+0

@NiranjanKalas:投稿を編集しました – Sandeep

答えて

1

私はあなたの接続に関する推測通り:

ERROR

は、あなたの接続文字列を確認します。

ConnectionString = "Server=localhost\instancename;Database=dbname;Uid=uid;Pwd=pwd;" 

とエラーがError Locating Server/Instance Specifiedです - ネットワークSQL Serverへの接続を確立する際に、関連するエラーまたはインスタンス固有のエラーが発生しました。サーバーが見つからなかったか、アクセスできませんでした。

localhostは、作業しているシステムを指します。別のコンピュータからこれにアクセスすると、エラーが発生します。あなたがそうであるように、私はこのような機能を実行すると

<connectionStrings> 

<add name=”SampleConnectionString” connectionString=”Data Source=machinename\instancename;Initial Catalog=AdventureWorks;Integrated Security=SSPI;Min Pool Size=5;Max Pool Size=60;Connect Timeout=30″ providerName=”System.Data.SqlClient”/> 

</connectionStrings> 

Connect via an IP address of your server

Server=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;

または

Server=IISPCNameまたはServer= IISPCName\InstanceName

:正しい接続文字列を設定するには、ヘルプ以下のように

例コンプをコピーする私のコンピュータのプロパティから子孫の名前を、インスタンスの名前を入力します。問題のようなタイプを解決するためのリンク次

チェック:
Resolving “A network-related or instance-specific error occurred while establishing a connection to SQL Server…”

注: あなたは上記の接続がうまくいかない場合、SQL Serverのリモートアクセス設定をチェックする必要があります。
How to configure SQL Server 2005 to allow remote connections
Remote Access Settings for SQL Server

接続文字列参照:それを動作させるためには、以下のリンクをチェック
Connection strings for SQL Server 2008

+0

IISとSQLサーバーが常に同じマシンに残るため、私はlocalhostを使用していました。そして、databseはwebserviceによってアクセスされていますか?localhostは動作するのでしょうか? – Sandeep

+0

Windows認証 'connectionString ="初期カタログ= MyDb;データソース= MyServer;統合セキュリティ= SSPI; " –

関連する問題