Deploy Problem with ASP.NET SQL Server connection issues

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • teddarr
    New Member
    • Oct 2006
    • 143

    Deploy Problem with ASP.NET SQL Server connection issues

    I have been working on an asp.net/sql server project for the last month and finally got to the point where I need to deploy it to IIS(port80)/ inetpub/wwwroot and run it from localhost instead of from within Visual Studio. The project deploys fine but when I go to the page with the first database connection, I get an error that basically says my table in the datatable can not be found. Since the project works great from Visual Studio 2005 I can only assume that there is a problem connecting to sql server. My sql server is set up to allow remote connections. I have tried it using windows authentication and sql server authentication. Is there another configuration setting I'm missing or what?

    Thanks,
    Ted
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    What's your connection string? How did you connect to your db? Could you issue a generic t-sql just to check if you are connected? You mentioned that the error showed that your table is missing. I'm not sure if you are connected or you just need to specify the full qualifier in accessing objects (ie dbname.owner.ob ject).

    -- CK

    Comment

    • teddarr
      New Member
      • Oct 2006
      • 143

      #3
      edit

      How did I connect:

      public DataSet GetUID(string uid)
      { DataSet ds = new DataSet();
      sqlComm = new SqlCommand();
      sqlComm.Connect ion = connectionStrin g;
      sqlComm.Command Type = CommandType.Sto redProcedure; sqlComm.Command Text = "Client_GetUID" ; sqlComm.Paramet ers.Add("@uid", SqlDbType.Text, 16).Value = uid;
      try
      {
      Helper.FillData Set(sqlComm, ds, "Users"); sqlComm.Command Text, ds, tableNames, SearchValue);
      if (!EventLog.Sour ceExists(sSourc e))
      {
      EventLog.Create EventSource(sSo urce, sLog);
      }
      sEvent = "App_Code/DataTier.GetUID Normal Operation"; EventLog.WriteE ntry(sSource, sEvent, EventLogEntryTy pe.Information, 301);
      }
      catch (SqlException ae)
      {
      if (!EventLog.Sour ceExists(sSourc e))
      {
      EventLog.Create EventSource(sSo urce, sLog);
      }
      sEvent = "App_Code/DataTier.GetUID :" + ae.ToString(); EventLog.WriteE ntry(sSource, sEvent, EventLogEntryTy pe.Warning, 101);
      }
      return ds;
      }

      connection string:

      Data Source=TedsLapt op;Initial Catalog=VoterTe st;Integrated Security=True;U id=teddarr;Pass word=xxxxxxxx" providerName="S ystem.Data.SqlC lient"

      Also tried this using windows authentication
      Data Source=TedsLapt op;Initial Catalog=VoterTe st;Integrated Security=True;" providerName="S ystem.Data.SqlC lient"

      I've just finished putting some event logging code into the program, but the data I got back so far is useless because I haven't put it in early enough in the workflow.

      Everything is telling me I am not getting a connection with the database, I just don't know why, nor have I proven 100% that this is what is happening.

      Any help is appreciated.

      Ted
      Last edited by teddarr; Oct 8 '08, 05:22 PM. Reason: formatting

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        I don't see any problem with your connection string (or maybe am just not seeing it). Try creating a sample apps that uses your connection string and connect to your server. Then do a simple t-sql.You have to isolate the problem first. Since you're not sure yet if it's really a connection problem, might as well find out first.

        -- CK

        Comment

        • teddarr
          New Member
          • Oct 2006
          • 143

          #5
          I know the connection string works from the app when I run it in Visual studio. I use the same connection string from windows apps that I have currently in production.

          The problem occurs only after I publish the project to the inetpub/wwwroot folder and run http://localhost from a browser.

          I think it is a sql server configuration problem.

          I've just littered the login.aspx page with event logging statements. Hopefully there will be a clue in there. I'll put in a method that checks for an open connection and call it from the Page_Load method to see what it says.

          I'll run it tonight and report the results.

          Comment

          • teddarr
            New Member
            • Oct 2006
            • 143

            #6
            The only message that I am getting is "Cannot open Database xxxxx requested by the login. The login failed. Login failed for user 'ComputerName\A SPNET'. at System.Data.Pro viderBase.DbCon nectionPool.Get Connection(DbCo nnection owingingObject.

            This is the text of the SqlException that is recorded in the event viewer.

            Everything works great until I publish to inetpub/wwwroot. I'm stumped.

            Could it have something to do with database ownership?

            Comment

            • ck9663
              Recognized Expert Specialist
              • Jun 2007
              • 2878

              #7
              I think your website is using ComputerName\AS PNET to connect to your sql server. Did you configure your IIS to use Integrated Windows Authentication?

              -- CK

              Comment

              • teddarr
                New Member
                • Oct 2006
                • 143

                #8
                I think you may be hitting on part of the problem.

                I have found a website that walks through the configuring of both sql server and the asp.net application. It addresses different scenarios and should get me on the right track.

                Here is the link for anyone else who has this problem:

                http://imar.spaanjaars .com/QuickDocId.aspx ?quickdoc=395

                Comment

                • teddarr
                  New Member
                  • Oct 2006
                  • 143

                  #9
                  The steps in the article listed above did lead me to a successful conclusion. It all had to do with 2 missing steps in the security configuration.

                  Thanks for your help.

                  Comment

                  Working...