Pregunta

I am using Visual Studio 2013. I am trying to create a WCF service. In this service I have a database. When I run this service it returns data. But when I am trying from client application I get an exception. I am using default Visual Studio 2013 SQL Server. Can anyone please help me? What is the problem and how can I solve it?

Error:

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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details. )
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at WindowsApplication1.ServiceReference1.IService1.login(String id, String password)
at WindowsApplication1.ServiceReference1.Service1Client.login(String id, String password) in e:\study\7thsemister\Paint app\Paint app\Service References\ServiceReference1\Reference.cs:line 77
at WindowsApplication1.login.login_btn_Click(Object sender, EventArgs e) in e:\study\7thsemister\Paint app\Paint app\login.cs:line 26

¿Fue útil?

Solución 2

first of all check you firewall setting. if your problem still exist, check client proxy setting. also check you sql server connection from client. for do this create a new text file and change filename.txt to filename.udl, now run it and check your connection.

if your problem does not solve, provide your code.

Otros consejos

If the code accessing the database is on a different machine from the SQL Server database itself, you may need to enable remote connections on the database, or modify the the SQL Server Network Configuration to allow a network protocol. To enable remote connections, open the properties of your database server from SQL Server Management Studio (on the database server) and select "Allow remote connections to this server". To enable a network protocol, open the "SQL Server Network Configuration" application and enable a protocol such as "TCP/IP".

Here's an article with detailed instructions: http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top