473,324 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

C#-App: Cannot connect to SQL Server

So I've created a Windows based application in C# that uses data from our databases on a service provider (crystaltech). The application has been deployed and has been working great on all our computers and all our clients computers, except for one... When every they try to login/communicate with the database it returns the following error:

Expand|Select|Wrap|Line Numbers
  1. System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
  2.    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
  3.    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
  4.    at System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner, Boolean& failoverDemandDone, String host, String failoverPartner, String protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean aliasLookup)
  5.    at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
  6.    at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
  7.    at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
  8.    at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
  9.    at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
  10.    at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
  11.    at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
  12.    at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
  13.    at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
  14.    at System.Data.SqlClient.SqlConnection.Open()
  15.    at ColeyClientSystem.Utils.DataManager.ExecuteScalar(String query)
  16.    at ColeyClientSystem.Login.AttemptLogin()
I've searched google for hours and tried just about every variation of a connection string using both sql and oledb connections. The current connection string causing this error is:
Expand|Select|Wrap|Line Numbers
  1. Data Source=xxx.xxx.xxx.xxx,1433;Network Library=DBMSSOCN;Initial Catalog=xxx;User ID=xxx;Password=xxx
and
Expand|Select|Wrap|Line Numbers
  1. Provider=SQLOLEDB;Data Source=xxx.xxx.xxx.xxx,1433;Persist Security Info=True;Password=xxx;User ID=xxx;Initial Catalog=xxx
I've also used:
Expand|Select|Wrap|Line Numbers
  1. Data Source=xxx.webcontrolcenter.com;Type System Version=SQL Server 2000;Integrated Security=False;Persist Security Info=True;Password=xxx;User ID=xxx;Initial Catalog=xxx
Everyone else connects fine and the software runs great, except this one user. I've also had them add the port in windows firewall in network connection settings, and nothing.

Here is the exact function causing the error:
Expand|Select|Wrap|Line Numbers
  1. public static String ExecuteScalar(string query)
  2. {
  3.     string connectionString = "Data Source=xxx.xxx.xxx.xxx,1433;Network Library=DBMSSOCN;Initial Catalog=xxx;User ID=xxx;Password=xxx";
  4.  
  5.     SqlConnection connection = new SqlConnection(connectionString);
  6.     connection.Open();
  7.     try
  8.     {
  9.         SqlCommand sqlcmd = new SqlCommand(query, connection);
  10.         return sqlcmd.ExecuteScalar().ToString();
  11.     }
  12.     catch
  13.     {
  14.         return "";
  15.     }
  16.     finally
  17.     {
  18.     if (connection.State == ConnectionState.Open)
  19.         connection.Close();
  20.     }
  21. }
The user is running Windows XP 5.1, and like I said only one user is getting this error. Thanks for you time.

Derek
May 29 '08 #1
10 3544
Plater
7,872 Expert 4TB
XP 5.1? I've never heard of that?
May 29 '08 #2
Curtis Rutland
3,256 Expert 2GB
XP 5.1? I've never heard of that?
Open up a command line and type "winver" and you'll see the actual version of the windows kernel you're using. XP is 5.1, Vista is 6.0, etc.
May 29 '08 #3
Plater
7,872 Expert 4TB
Huh how about that.
I've always gone with "XP Pro SP1" or "SP2" (or I guess now it could be "SP3")

Anyway, Is there anything else different about this PC/User? Are they on/not on a domain? Do they have different credential security levels?
Do they have some version of SQL Server (or the freebee ones) running locally on their PC.

I see that it looks like you use an OLEDB driver in your connection string, is that setup as a userDSN/SystemDSN/fileDSN or whatever is correct? Does that connection have the correct default settings and permissions?
May 29 '08 #4
Its really hard to tell what is different on the machine being that they are in Utah and I'm in Texas. From what I understand she is not on a network, talked to the ISP and they said it wasn't anything they were blocking on their end. As far as having a version of SQL Server on the machine, I highly doubt it...

I guess my question is what else could be blocking her access to our data servers/our servers blocking her? My connection strings are good and other people from all over the US dont have any issues. cmd -> ping the database ip gets a response.

I'm not quite sure what you mean by "Do they have different credential security levels?", and the olebd connection is generated by VS and i got that connection string from the app.config file.

Thanks for your help guys.

Derek
May 29 '08 #5
Curtis Rutland
3,256 Expert 2GB
I see that it looks like you use an OLEDB driver in your connection string, is that setup as a userDSN/SystemDSN/fileDSN or whatever is correct?
OleDb doesn't rely on DSNs. It just needs the provider to be installed on the machine. ODBC is the one that uses DSNs.
May 29 '08 #6
Plater
7,872 Expert 4TB
OleDb doesn't rely on DSNs. It just needs the provider to be installed on the machine. ODBC is the one that uses DSNs.
Hehe I get them mixed up all the time, don't like 'em.

I wasn't aware that the computer located elsewhere, i thought we were talking like "withen an office complex" type situation. So I guess none of that stuff applies.

Does that user have a slow internet connection? Connection timeout is listed in the error message as a possible source of the problem (although I've almost never seen it be the actual problem).

Could you perhaps generate a really small/light-weight program that just attempts to connect to the database. Perhaps fill it with debug code and send it off to them to see if it can tell you anything more? Give it like super long timeout for connecting and such?
May 30 '08 #7
Could you perhaps generate a really small/light-weight program that just attempts to connect to the database. Perhaps fill it with debug code and send it off to them to see if it can tell you anything more? Give it like super long timeout for connecting and such?
I basically did that...I put a function at the beginning of the application that tested like 10 different connection string that work for me, and every one returned the same error message as above. I dont think that its a time out issue because I was talking to her over then phone when she ran it and the application started up in about the same amount of time, but Ill give it a try anyways. I did something like this:
Expand|Select|Wrap|Line Numbers
  1. string connString = ...;
  2. SqlConnection conn = new SqlConnection(connString);
  3. try conn.Open();
The only thing that I really gathered was ErrorCode -2146232060 for the sql and ErrorCode -2147467259 for the oledb.

I really think its like a firewall or something else blocking the port, can you give me some info on disabling these thing? Until then, back to google...

Derek
May 30 '08 #8
Plater
7,872 Expert 4TB
Sometimes anti-virus software has their own firewall (Norton Security is one I think) that could be blocking it?
Is there anyone else at that location that can use it fine?
May 30 '08 #9
madankarmukta
308 256MB
Could you once try with bypassing the mentioned IP address of the DataSourse in the connection string from the proxy ?
Or else just write the hostname of the Ipaddress in the DataSource attribute and bypass hostname from the proxy.

Thanks!
May 31 '08 #10
Hi

i was facing the error when opening connection using sqlconnection

nw got solved


http://sqlservererror-info.blogspot....ablishing.html

http://aspnetmembershipprovider.blog...ablishing.html


See This
Jul 22 '09 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jack Smith | last post by:
Hello, I have PHP 4.3.1.1 running on Windows 2000 Server with IIS 5. This connects to an MS SQL 7 server running on a seperate NT4 box. Recently, this SQL7 Server had SQL7 Service Pack 4...
2
by: Krista | last post by:
Hi, I hope you guys can help me out~~~ when I run it localhost/config.php, it cannot display any message such as connect successfully or failed. Do u guys have any idea? config.php <html>...
2
by: Hari Om | last post by:
Cannot connect as Internal Hello, I am using IBM AIX 5.1L box for Oracle 9.2.0.1. I cannot connect as internal to my DB INstance - wonder why? Here is what is do:...
3
by: JM | last post by:
Good day. I was able to connect to a database server using SQL Server Enterprise Manager. The Server name specified on the tree is JOMARGON(Windows NT). But no server was detected using either...
0
by: Byron Hopp | last post by:
We seem to connect o.k. when we have a network cable plugged into our workstation. But when the network cable is unconnected we cannot connect to a SQL server which is on the same laptop as my...
5
by: smatta | last post by:
I have just installed MySql version 5.0-18 on Red Hat Fedora Core 4. It is running but I cant connect to it using MySql Query Browser running on my pc. >From my pc, I can telnet to the sql...
2
by: zMisc | last post by:
I am using VB.NET 1.1 and cannot connect to a MySQL (v5) database. I've done the following: 1) Create a DSN for MyODBC. 2) Connect using: Driver=MySQL ODBC 3.51 Driver; Server=localhost; Data...
1
by: bitchanger | last post by:
I have installed an SQL Server 2000 Developer Edition (SP4) on a computer that has Windows Server 2003 on it.The server is connected to the workgroup "WORK" and has no Active Directory. Now I...
1
by: rubeel | last post by:
I cannot seem to connect to this Instance locally which was i able to in the past. I can connect to the instance from out side. The instance is running and the DBs in the instance are available and...
1
by: newphpcoder | last post by:
Good day! I am newly in SQL Server 2005 and now I encountered error when i try to login. This is some of the information: Microsoft SQL Server 2005 Express Edition Server Type: Database Engine...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.