المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : c# with a WPF GUI



C# Programming
04-01-2009, 11:52 AM
Ok, My appologies if this is in the wrong section. I couldnt tell if it was a problem with sql server, or my code.

Im building a small app that grabs some data out of my sql server express 2005 database, and tosses it into a dropdown list. Simple enough.

I decided to go with a WPF gui, so I could drop it onto my web server and view it via IE.

My app works great on every box I try it on, on the local network (after getting all the certificate validation done). However, when I try to access it from a computer from outside the network, it runs into a bunch of sql server exceptions. My web server and sql server are running on the same machine.

I dont know if its the connection string failing from an outside network, or maybe I just dont understand how its trying to access the sql server. Here is the connection string I use to establish the connection.

SqlConnection con = new SqlConnection(string.Format(@"Data Source=MyComputerName\SQLEXPRESS;Initial Catalog=MYDB;User Id=me;Password=mypw;"));

When I connect to my .xbap file on the webserver from outside the network, I get 'An error occurred in the application you were using' and the following error in the 'More Information'

--The Error is quite verbose, so i tried to only include a portion of it--

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> 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.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)


If more information would be useful, let me know.