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 8542277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:01:27+00:00 2026-06-11T12:01:27+00:00

I have a asp.net site that works fine on my local computer,it has a

  • 0

I have a asp.net site that works fine on my local computer,it has a function to create and open connection (sql server 2008 R2)
I bought a VPS and I uploaded my source in it, when I call the function it fails to connect to data base because the data source is wrong!
it’s the error it recieve:

    {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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Here is my code which works on my computer:

    public ClientHandle()
    {
        SqlConnection con = new SqlConnection("Server=localhost;Data Source=ARASH-PC;User ID=sa;password=*****;Initial Catalog=Ranker;Trusted_Connection=False;Integrated Security=False;");
     con.open();

    }

when I uploaded my source to my VPS I changed the Data source to my IP:

    public ClientHandle()
    {
        con = new SqlConnection("Server=localhost;Data Source=209.54.48.101;User ID=sa;password=*****;Initial Catalog=Ranker;Trusted_Connection=False;Integrated Security=False;");
    }

But it can’t connect to data base!what is wrong with my code?what’s my mistake?

  • 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-06-11T12:01:28+00:00Added an answer on June 11, 2026 at 12:01 pm

    Try this:

    con = new SqlConnection("Server=209.54.48.101;Database=Ranker;User ID=sa;Password=*****;Trusted_Connection=False;Integrated Security=False;");
    

    Connection strings for SQL Server 2008

    Standard Security

    Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername; Password=myPassword;
    

    OR

    Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET MVC project that works fine on my local machine (no
I have a web site that is designed in asp.net and working fine in
I have an asp.net mvc 3 site running locally and everything works fine. I
I have an ASP.Net MVC site that has a subdomain for each customer e.g.
I have a web site built using ASP.NET MVC4 that I can publish fine
I have a ASP.NET MVC site and it works just fine when I run
I have a project (.NET 3.5 C#) that works fine on the local machine
I have a asp.net web site that was developed on the .Net Framework v2
I have a asp.net mvc site that references a couple of libraries. Recently I
I have an ASP.NET MVC 3 site that makes use of a ClientDependency framework

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.