Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 910013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:58:34+00:00 2026-05-15T16:58:34+00:00

UPDATE: I have determined that the SQLClient code times out on the first call,

  • 0

UPDATE: I have determined that the SQLClient code times out on the first call, but works on all subsequent calls. Also, when connecting with Management Studio, it times out the first time as well, then connects when I try again. Ideas?

Original:
Hey guys,
I have a very strange issue that I can’t seem to resolve. I have an application that connects to several different versions of SQL Server. I have no problems connecting to 2005 or 2008 R2. But I am having timeout issues with 2008 Standard. I even wrote a sample app to try and troubleshoot this. Here’s the sample code that works:

OdbcConnection conn = null;
OdbcDataAdapter adp = null;
DataSet resultSet = new DataSet();
DataTable result = null;

string queryString = Query.Text;
conn = new OdbcConnection(@"Driver={SQL Server Native Client 10.0};Server=MyServer\DataSource;Database=MyDatabase;Uid=MyUser;Pwd=ThePassword;");
conn.Open();
adp = new OdbcDataAdapter(queryString, conn);
adp.Fill(resultSet);
result = resultSet.Tables[0];
ResultsGrid.DataSource = result;

Now here the sample code that times out:

SqlConnection conn = null;
SqlDataAdapter adp = null;
DataSet resultSet = new DataSet();
DataTable result = null;

string queryString = Query.Text;
conn = new SqlConnection(Application Name=HCGPrevision; Data Source=MyServer\DataSource; Initial Catalog=MyDatabase;UID=MyUser;PWD=ThePassword;);
conn.Open();
adp = new SqlDataAdapter(queryString, conn);
adp.Fill(resultSet);
result = resultSet.Tables[0];  //Assume only one result set/table.
ResultsGrid.DataSource = result;

This second set of code will work on a database in SQL Server 2008 R2, but not the Standard/R1 version. The connection string seems to work fine for any other SQL Server but won’t work for this one. We have been using this code for over 5 years and never had this issue. I made sure that SQL has Named Pipes enabled and Mixed (Windows/SQL) Authentication. The fact that the ODBC will work but not the SQL is bizarre. Please let me know what I’m missing!

Thanks,

Erick

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:58:34+00:00Added an answer on May 15, 2026 at 4:58 pm

    Okay, I finally figured out an answer to this. It tested my code against SQL2005 and started getting the same problem. So I did some more searching and stumbled on this:

    http://blogs.msdn.com/b/adonet/archive/2010/04/18/sqlclient-default-protocol-order.aspx

    I added "np:" to the Data Source in my connection string and Viola! Connection time!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a (rather complex) app that works fine on iOS 4 but fails on
UPDATE I have updated my code in response to @MichaelRushton comments. I am now
UPDATE - I have fixed some mistakes in the code below and the images
I have update panel that content check box, textbox, 3 DropDownList with CascadingDropDown extender.
I use oracle 10. I have update statement like that : update table1 t1
I have an UPDATE statement that's intended to update a status field for a
I have a SQL Compact Edition Database that I update periodically (via web services).
I have a table like this: | Update | Name | Code | modification
I have written a simple script that calls a function in a while loop.
I have a trigger that executes a function on table insert or update. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.