Unable to connect to SQL remotely through SqlConnection???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?VG9kZCBKYXNwZXJz?=

    #1

    Unable to connect to SQL remotely through SqlConnection???

    Hey guys,

    I've written a web application that I'm simply trying to use to
    access a database. When I run the application locally (or as an NT Service)
    it can easily access the remote SQL database. However, when I host the item
    as a web application, it can ONLY access local SQL databases on that server,
    and NOT remote SQL databases (even if it's on our network). Like I said, I
    can access those same databases when I run the program in localhost, but NOT
    when it's hosted.

    What could the problem possibly be? I don't get any errors, it just doesn't
    pull up any data.

    This are the connection strings that I've tried, neither of which work. I've
    created a local ODBC connection to the database, and the ODBC connection has
    no problem connecting to the server with the SQL database on it, but it just
    doesn't work when I'm accessing it remotely. I don't get any errors, there
    just isn't any data.

    For obvious reasons, I've changed the info below.


    Any help you guys can give me, I'd really appreciate it!!!


    THanks!!!



    // SqlConnection sqlConn2 = new SqlConnection(" user id=XXXXXX" +
    // "password=XXXXX X;server=SERVER NAME;" +
    // "Trusted_Connec tion=yes;" +
    // "database=datab ase_name; " +
    // "connection timeout=30");

    SqlConnection sqlConn2 = new SqlConnection(" Data Source=database _name;
    connection timeout=30");

  • Ignacio Machin \( .NET/ C# MVP \)

    #2
    Re: Unable to connect to SQL remotely through SqlConnection?? ?

    Hi,
    "Todd Jaspers" <ToddJaspers@di scussions.micro soft.comwrote in message
    news:ADE41A59-EEC7-4593-BE87-3623ADFC045F@mi crosoft.com...
    Hey guys,
    >
    I've written a web application that I'm simply trying to use to
    access a database. When I run the application locally (or as an NT
    Service)
    it can easily access the remote SQL database. However, when I host the
    item
    as a web application, it can ONLY access local SQL databases on that
    server,
    and NOT remote SQL databases (even if it's on our network). Like I said, I
    can access those same databases when I run the program in localhost, but
    NOT
    when it's hosted.
    >
    What could the problem possibly be? I don't get any errors, it just
    doesn't
    pull up any data.
    What surprise me is taht you get no error, you should get at least a
    connection error

    do you have a firewall for any change?
    This are the connection strings that I've tried, neither of which work.
    I've
    created a local ODBC connection to the database, and the ODBC connection
    has
    no problem connecting to the server with the SQL database on it, but it
    just
    doesn't work when I'm accessing it remotely. I don't get any errors, there
    just isn't any data.
    But you are not using ODBC though.


    Comment

    • =?Utf-8?B?VG9kZCBKYXNwZXJz?=

      #3
      Re: Unable to connect to SQL remotely through SqlConnection?? ?

      Exactly! It's very weird. There is absolutely NO error. It just simply does
      NOT populate the data. But when I run it locally in VS2005 where it runs it
      from Local Host, it pulls up the data just as it should. NO error AT ALL.
      Form loads fine, the data just isn't there. Everything else is the same.

      I really have no idea if there's a firewall or not. It's very frustrating.
      The IT guys pass out group policy, make changes all the time, and they don't
      tell us. I complain about it constantly, but they're still learning the ropes
      of AD I suppose.

      How would I be able to tell if 1433 is being blocked or firewalled?



      "Ignacio Machin ( .NET/ C# MVP )" wrote:
      Hi,
      "Todd Jaspers" <ToddJaspers@di scussions.micro soft.comwrote in message
      news:ADE41A59-EEC7-4593-BE87-3623ADFC045F@mi crosoft.com...
      Hey guys,

      I've written a web application that I'm simply trying to use to
      access a database. When I run the application locally (or as an NT
      Service)
      it can easily access the remote SQL database. However, when I host the
      item
      as a web application, it can ONLY access local SQL databases on that
      server,
      and NOT remote SQL databases (even if it's on our network). Like I said, I
      can access those same databases when I run the program in localhost, but
      NOT
      when it's hosted.

      What could the problem possibly be? I don't get any errors, it just
      doesn't
      pull up any data.
      >
      What surprise me is taht you get no error, you should get at least a
      connection error
      >
      do you have a firewall for any change?
      >
      This are the connection strings that I've tried, neither of which work.
      I've
      created a local ODBC connection to the database, and the ODBC connection
      has
      no problem connecting to the server with the SQL database on it, but it
      just
      doesn't work when I'm accessing it remotely. I don't get any errors, there
      just isn't any data.
      >
      But you are not using ODBC though.
      >
      >
      >

      Comment

      • =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=

        #4
        RE: Unable to connect to SQL remotely through SqlConnection?? ?

        Todd, "No error" is kind of a blanket statment. Have you tried something like
        this?

        SqlConnection sqlConn2 = null;
        try
        {
        sqlConn2 = new SqlConnection(" Data Source=database _name;
        connection timeout=30");
        }

        catch(SqlExcept ion sqlex)
        {
        System.Diagnost ics.Debug.Write Line(ex.Message +);
        }

        finally
        {
        sqlConn2.Close( );
        }

        I bet you will see something in the output window in debug mode. Get in the
        habit of wiring up your code with exception handling; it will save you a lot
        of time.
        -- Peter
        Recursion: see Recursion
        site: http://www.eggheadcafe.com
        unBlog: http://petesbloggerama.blogspot.com
        BlogMetaFinder: http://www.blogmetafinder.com



        "Todd Jaspers" wrote:
        Hey guys,
        >
        I've written a web application that I'm simply trying to use to
        access a database. When I run the application locally (or as an NT Service)
        it can easily access the remote SQL database. However, when I host the item
        as a web application, it can ONLY access local SQL databases on that server,
        and NOT remote SQL databases (even if it's on our network). Like I said, I
        can access those same databases when I run the program in localhost, but NOT
        when it's hosted.
        >
        What could the problem possibly be? I don't get any errors, it just doesn't
        pull up any data.
        >
        This are the connection strings that I've tried, neither of which work. I've
        created a local ODBC connection to the database, and the ODBC connection has
        no problem connecting to the server with the SQL database on it, but it just
        doesn't work when I'm accessing it remotely. I don't get any errors, there
        just isn't any data.
        >
        For obvious reasons, I've changed the info below.
        >
        >
        Any help you guys can give me, I'd really appreciate it!!!
        >
        >
        THanks!!!
        >
        >
        >
        // SqlConnection sqlConn2 = new SqlConnection(" user id=XXXXXX" +
        // "password=XXXXX X;server=SERVER NAME;" +
        // "Trusted_Connec tion=yes;" +
        // "database=datab ase_name; " +
        // "connection timeout=30");
        >
        SqlConnection sqlConn2 = new SqlConnection(" Data Source=database _name;
        connection timeout=30");
        >

        Comment

        • =?Utf-8?B?VG9kZCBKYXNwZXJz?=

          #5
          RE: Unable to connect to SQL remotely through SqlConnection?? ?


          Thanks Peter, I appreciate this. I'll try this now.


          "Peter Bromberg [C# MVP]" wrote:
          Todd, "No error" is kind of a blanket statment. Have you tried something like
          this?
          >
          SqlConnection sqlConn2 = null;
          try
          {
          sqlConn2 = new SqlConnection(" Data Source=database _name;
          connection timeout=30");
          }
          >
          catch(SqlExcept ion sqlex)
          {
          System.Diagnost ics.Debug.Write Line(ex.Message +);
          }
          >
          finally
          {
          sqlConn2.Close( );
          }
          >
          I bet you will see something in the output window in debug mode. Get in the
          habit of wiring up your code with exception handling; it will save you a lot
          of time.
          -- Peter
          Recursion: see Recursion
          site: http://www.eggheadcafe.com
          unBlog: http://petesbloggerama.blogspot.com
          BlogMetaFinder: http://www.blogmetafinder.com
          >
          >
          >
          "Todd Jaspers" wrote:
          >
          Hey guys,

          I've written a web application that I'm simply trying to use to
          access a database. When I run the application locally (or as an NT Service)
          it can easily access the remote SQL database. However, when I host the item
          as a web application, it can ONLY access local SQL databases on that server,
          and NOT remote SQL databases (even if it's on our network). Like I said, I
          can access those same databases when I run the program in localhost, but NOT
          when it's hosted.

          What could the problem possibly be? I don't get any errors, it just doesn't
          pull up any data.

          This are the connection strings that I've tried, neither of which work. I've
          created a local ODBC connection to the database, and the ODBC connection has
          no problem connecting to the server with the SQL database on it, but it just
          doesn't work when I'm accessing it remotely. I don't get any errors, there
          just isn't any data.

          For obvious reasons, I've changed the info below.


          Any help you guys can give me, I'd really appreciate it!!!


          THanks!!!



          // SqlConnection sqlConn2 = new SqlConnection(" user id=XXXXXX" +
          // "password=XXXXX X;server=SERVER NAME;" +
          // "Trusted_Connec tion=yes;" +
          // "database=datab ase_name; " +
          // "connection timeout=30");

          SqlConnection sqlConn2 = new SqlConnection(" Data Source=database _name;
          connection timeout=30");

          Comment

          Working...