none
A network-related or instance-specific error occured while establishing a connection to SQL server !!!!

    Question

  • Hello everyone,

     I am working on a project using VS2010 SQL2008 and I saw an ODD behaviour , First let me tell you that the app runs without any problem in my developing pc (Windows Xp sp3 32bit)

     But when I was trying the application in another pc (Windows 7 32bit)

     I got this exception: A network-related or instance-specific error occured while establishing a connection to SQL server.The server was not found or was not accessible.Verfiy that the instance name is correct and that SQl server is configured to allow remote connections.

     Now what is weird in this exception; Is when the application reaches the DataAdpater.Fill(dataset) line I got this exception but when the app reaches the DataAdpter.Insert(....) It runs without any problem .

     And what is more weird is that I noticed that the dataset that is used in the previous insert procedure can later be filled with dataAdapter.Fill(...) procedure which it was giving me an exception before .

     Now I hope you understand my problem

     I tried these things as a solution:

     1)Checked SQlBrowser running..

     2)No aliases to Sql server at all to remove...

     3)remote area connection--OK

     4)TCP and UDP port 1433,1434 exception in firewall

     5)Unistalled my only antivirus Norton

     6)Added Tcp/IP ports in Sql protocols

    7)My connection String is : onnectionString="Data Source=ALI\SQLEXPRESS;Initial Catalog=PALMSDATABASE;Integrated Security=True"

    8)Also tried using Sql Server authentication (user Id and password)

     My question is what is the difference between fill and insert?

    Is there a problem with my connection?

     My app. runs smoothly on the original pc ,What should I do?

    Please If anyone knows anything help me, I am very desperate.

    and about to lose my mind

    Tuesday, August 23, 2011 1:11 AM

Answers

  • So your problem is Windows7/Server 2008 (same system) related.

    There should be something special which you do, which is related to the user who is running the application. 

    Are you sure that both the client and the server are running on the same LAN with for the user set the integrated security in the AD?

    Otherwise this sounds more as a question for the technet people

    http://technet.microsoft.com/forums

    If a program runs on computer A and not on Computer B than there is in fact nothing wrong with the program.

     


    Success
    Cor
    Monday, August 29, 2011 5:28 AM
  • Sorry To be late ,

    First of all I 've tried all the points mentioned on the net without any benefit.

     Second my app works without any problem in original developing Pc but in another Pc it does not.

    I found out that the problem was with multiple connection strings,

     Let me explain, My app is N-tier app,The dataset itself is in isolated project with it 's own connection string.

     The Main project has also a connection string for some data work. So we end up with a solution that contains two connection string ,This will give you the above error even if the connection strings are correct which was my case.
    So I readjust the app and made One-connectionString-App and it worked like a charm.

    I hope this will help you guys.


    Ali Haider

    • Marked as answer by Ali Haider Saturday, September 17, 2011 3:17 AM
    • Edited by Ali Haider Saturday, September 17, 2011 3:18 AM
    Saturday, September 17, 2011 3:14 AM

All replies

  • First of all you need to confirm that your client pc can connect to the SQL server at computer Name "ALI". To do this we are going to use UDL file (Universal Data Link Adapter ).

    • Open Note pad create a blank file with extension *.UDL ( Type All files *.* )
    • go to explorer open this file by double clicking it.
    • Select your provider browse for server and connect to database.
    • After you have connected to the database, right click the *.UDL file and open it with notepad, copy all its contents and paste it here.

    Please mark those posts as answer which answers your question. Faraz
    Tuesday, August 23, 2011 8:22 AM
  • [oledb] ; Everything after this line is an OLE DB initstring Provider=SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;User ID="";Initial Catalog=PalmsDataBase;Data Source=Ali\SqlExpress;Initial File Name="";Server SPN=""

     I set it to Windows integrated security--->Test connection succeded

    Thanks in advance,But I told you before that the connection is ok and infact when I call the insert procedure it runs without problem after that I can call the fill procedure on the same table or dataset and it also works

     BUT If I call the fill procedure first in the begining of the program that error appears ....

     I discovered this by chance , You know we all call the fill procedure in the begining of the app.
    Please help me I do not know What to do.

     PS. the app runs without any problem in original developing pc


    Ali Haider

    Tuesday, August 23, 2011 5:38 PM
  • The reason that this error normally occurs is when either the database is not available, or it is not able to connect using the connection string that you have provided.

    The purpose of UDL file was to confirm that you have a proper access  to the SQL server and your connection string is correct.

    You know we all call the fill procedure in the begining of the app ?

    Yes we all call the fill procedure in the load event or at the beginning of the application but even before we call this fill procedure we setup the SQL connection.  In your case i have a doubt that you are not setting up the connection before using fill adapter. make sure you are connected to the database before calling fill procedure.


    Please mark those posts as answer which answers your question. Faraz
    Wednesday, August 24, 2011 3:34 AM
  • In Sql server Management studio I can access the database, I tried UDL and test connection--->Succeded

    I tried to change from Windows Authentication to Sql server authentication ,On the developing Pc it is working but on this Win 7 pc it is not and it gives me the same error

    (...In your case i have a doubt that you are not setting up the connection before using fill adapter. make sure you are connected to the database before calling fill procedure...)

    I told you that I CAN insert into the database and I CAN fill the dataset after that ,Isn't this enough of proof that there is a connection with the database even if it was a partial one,

    I am thinking of Windows 7 and it's security and access issues????

    This error drives me nut,I am losing it No one knows one definitive solution to this error and in my case it is more weired as it connects in case of INSERT and does not in case of FILL !!!


    Ali Haider

    Wednesday, August 24, 2011 8:16 PM
  • Hi Ali,

    If this issue was caused by the Windows 7 security, have you tried running your application as administrator?

    Run application with administrator privilege, please read: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/7f8e2b2b-98cc-41fd-a217-65ebce493f3f

    Best Regards,


    Kee Poppy [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, August 25, 2011 7:11 AM
  • If I understand your problem well it looks the most to a connection time out problem. 

    That can be set (set it never to always).

    http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx

    If this does not help to solve your problem than there is a tool 

    The SQL proviler, it is like it seems with everything with database servers a strange name for an access monitor.

    http://msdn.microsoft.com/en-us/library/ms187929.aspx


    Success
    Cor
    Thursday, August 25, 2011 7:29 AM
  • Thank you Kee Poppy,

    I tried your idea and run it As an Administrator --->does not help

    But I am still thinking of Win 7 security.

     

    Thank you Cor Lightert,

    But if it was a Conn time issue,Why it does not tell me Connection Time-out error?!

    Anyway I tried Connection TimeOut=600000 and after a long waiting it gives me the same error

    I think I will give a try for Sql server Profiler

    I just want to tell you that the concept of my app is very simple Which is:

    In the begining it searches for registered users in the database,If there is any one registered (FILL procedure) then get it and put it on the listbox if no user registered then open a new window to register (INSERT procedure then Fill) a new user

    Well everything is working in my original PC (Win XP) as expected but in another PC (Win 7)

    It gives me an error when I try to fill the dataset in the first time only.

    I hope it is clear .


    Ali Haider
    Thursday, August 25, 2011 3:24 PM
  • Hello guys,
    guess what I did,
    I installed Virtual Machine and installed Windows Xp SP3 using VM.

    In the virgin new windows I did only these things:

    Installed .Net framework 4.0
    Installed Sql server 2008
    Installed Crystal report runtime 11 for .net framwork 4.0
    Installed Microsoft Installer 4.5
    Installed My Application

    And then I run my app,guess what happened .....
    I got the same error :.( Why is this happening ,Help me please.
    Ali Haider
    Monday, August 29, 2011 1:24 AM
  • What the target PC name? In your Connection String it is Ali/SQLExpress. The target PC SQL is running with the same name?

    Thanks.


    If my post answers your question then mark as answer.
    Monday, August 29, 2011 3:06 AM
  • So your problem is Windows7/Server 2008 (same system) related.

    There should be something special which you do, which is related to the user who is running the application. 

    Are you sure that both the client and the server are running on the same LAN with for the user set the integrated security in the AD?

    Otherwise this sounds more as a question for the technet people

    http://technet.microsoft.com/forums

    If a program runs on computer A and not on Computer B than there is in fact nothing wrong with the program.

     


    Success
    Cor
    Monday, August 29, 2011 5:28 AM
  • I have solved the problem and I will post the solution soon
    Ali Haider
    Sunday, September 11, 2011 5:47 PM
  • Hi Ali,

    Welcome to MSDN Forum.

    We're glad to hear that you figured out this problem. Cheers!

    It's appreciated that you would like to share your solutions & experience here. It will be very beneficial for other community members who have similar questions.


    Martin Xie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, September 12, 2011 3:31 AM
  • Sorry To be late ,

    First of all I 've tried all the points mentioned on the net without any benefit.

     Second my app works without any problem in original developing Pc but in another Pc it does not.

    I found out that the problem was with multiple connection strings,

     Let me explain, My app is N-tier app,The dataset itself is in isolated project with it 's own connection string.

     The Main project has also a connection string for some data work. So we end up with a solution that contains two connection string ,This will give you the above error even if the connection strings are correct which was my case.
    So I readjust the app and made One-connectionString-App and it worked like a charm.

    I hope this will help you guys.


    Ali Haider

    • Marked as answer by Ali Haider Saturday, September 17, 2011 3:17 AM
    • Edited by Ali Haider Saturday, September 17, 2011 3:18 AM
    Saturday, September 17, 2011 3:14 AM
  • please tell me how you fixed this, this is exactly the issue I am having I think it is windows 7 related but I need to provide the proof,  Please help me by detailing what you did to solve this issue, thank you.
    Monday, January 07, 2013 5:12 PM