Hello fellow daniwebians, I'm attempting to wrap up an asp.net/c# eCommerce website recently created (recently discussed in many of my posts). I'm now trying to transfer the finished product from my local development environment to a remote host.

I can publish the files fine, I can reset the connection-strings as needed for my actual SQL server connection (where I pull product info from), but I can't seem to upload the database schema that is generated locally (temporary instances). This instance is created temporarily for the purposes of a model-driven shopping cart (loosely based off of this tutorial http://www.asp.net/web-forms/tutorials/aspnet-45/getting-started-with-aspnet-45-web-forms/shopping-cart).

I've changed the web.config file so that <compilation debug="false"/> , but whenever I go to the publish dialogue box, the only configuration setting I have is debug, not release (right click project name in solution explorer -> click publish web site -> click on Settings tab). Could this be part of the issue?

Hoping I don't have to manually create this database myself or something, as that would be tedious and makes migrations useless. Any ideas are much appreciated!

On a side note: I noticed these lines in the web.config file

<sessionState mode="InProc" customProvider="DefaultSessionProvider">
      <providers>
        <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx" connectionStringName="DefaultConnection"/>
      </providers>
    </sessionState>

Will I need to alter this in any way after the schema upload?

After doing a bit of research it appears those lines of code I found may be directly related to my problem.

I get the error...

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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

I changed the lines of code to...

<sessionState 
      mode="SQLServer" 
      allowCustomSqlDatabase="true"
      sqlConnectionString="workstation id=something.com;packet size=4096;user id=USERNAME;pwd=PASSWORD;data source=something.com;persist security info=False;initial catalog=MSSQLSERVER"
    />

The connectionstring was provided as is by the hosting provider and I've successfully pinged the server. I still however get the same error.

Any ideas?

If you are trying to access the DB from your computer at home, its unlikely your provider is going to allow that traffic in from the Internet. Usually providers only allow the DB traffic to come from their hosting servers. Check with your provider directly regarding options around your DB requirements.

This is run directly from the hosting server. As of right now I'm just trying to create a shopping cart using sessionstate (this is the element responsible for the cart I assume after reading for some time now). So this would have to be saved server-side temporarily from what I understand. I've run my program locally and it creates temporary tables to use for such things.

When a new client begins interacting with a Web application, a session ID is issued and associated with all the subsequent requests from the same client while the session is valid. This ID is used to maintain the server-side state that is associated with the client session across requests. The <sessionState> element controls how the ASP.NET application establishes and maintains this association for each client. ( http://msdn.microsoft.com/en-us/library/h6bb9cz9(v=vs.85).aspx )

I haven't even got a chance to address the issue of product information (actual seperate SQL server queries). The very first page of my website has only hard-coded elements and the number of items in the current users cart (so it immediately breaks on load).

Thank you for the idea though.

Wow man, another obvious case of me just not walking away for a second. The person who gave me this hosting account neglected to mention it was a free asp.net host and the free version doesn't allow remote database access apparently. Loss of hair and hours of time for no good reason but my laziness to check the account I was given.

Thanks for the help JorgeM!

I stand corrected, I've published the website to a provider which allows asp.net framework 4.5, allows remote access, and all minimum requirements... still the same unreachable SQL error.

I've tried changing the SQL server instance name to blank (blank for default) via Tools -> Options -> Database Tools -> Data Connections... still no luck.

I've read a few things about moving from SQL express locally to full version on the web-host server causing problems, but have yet to find a solution for this.

I've also read that I may need to create .SQL script files to recreate the actual database... not sure on this one either... researching now

Anyone have any ideas?

How have you created your online database? It should state somewhere how you would access it.

I've also read that I may need to create .SQL script files to recreate the actual database... not sure on this one either... researching now

This is exactly the procedure I've done in the past when creating a new DB on a provider's site. Generate the scripts from your copy. upload the scripts and execute them on the provider's platform using their "admin/console" tools.

In any event, I would have to assume that the preferred procedure will be published on your provider's help/FAQ page.

ok, now I'm really confused! I commented out the entire connectionstring in web.config, commented out the portion that deals with displaying the cart total items (front-end) in site.master, commented out the PreRendered-called function that counts the cart items on page load from site.master.cs, commented out everything that has to do with sessionstate in web.config.

I still get the same unreachable error... everything runs fine on my local machine.

Ok, so there are a few things you are working with in this thread. Lets go back to one of your first questions ...

<sessionState mode="InProc" customProvider="DefaultSessionProvider">
  <providers>
     <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx" connectionStringName="DefaultConnection"/>
  </providers>
</sessionState>

Will I need to alter this in any way after the schema upload?

InProc is the default setting, so im not sure why you are including this in your web.config. What is the reason?

if you dont need it then this section should be removed from your web.config.

<sessionState 
      mode="SQLServer" 
      allowCustomSqlDatabase="true"
      sqlConnectionString="workstation id=something.com;packet size=4096;user id=USERNAME;pwd=PASSWORD;data source=something.com;persist security info=False;initial catalog=MSSQLSERVER"/>

If you are trying to connect your site to your DB for your SQL queries, then you should have something like this in your web.config file...

<connectionStrings>
    <add connectionString="Data Source=xxxxxxx.hostedresource.com;Initial Catalog=DBNAME; User Id=DB_USERID;Password=DB-PWD;" name="MY-CON-NAME" providerName="System.Data.SqlClient" />
  </connectionStrings>

Not trying to connect to my own SQL using connectionstring just yet, just trying to get the local shopping cart to work. I reverted back to an older version of my project.
commented these lines out to narrow down the problem...
1) site.master

<li><a style="color:white;" runat="server" href="~/ShoppingCart" ID="cartCount">&nbsp;</a></li>

2) site.master.cs

protected void Page_PreRender(object sender, EventArgs e)
        {
            using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
            {
                string cartStr = string.Format("Cart ({0})", usersShoppingCart.GetCount());
                cartCount.InnerText = cartStr;
            }
        }

3) web.config

<sessionState mode="InProc" customProvider="DefaultSessionProvider">
      <providers>
        <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx" connectionStringName="DefaultConnection" />
      </providers>
    </sessionState>

Noticed this line of code in my IdentityModel.cs, not sure if it applies to this... did not modify it.

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
        public ApplicationDbContext()
            : base("DefaultConnection")
        {
        }
    }

It seems to work when I completely remove the sessionstate and calls to object models involved with it. This is the temporary instance of SQL I was refering to. The problem is, there is no permanent database created, it's an instance. How would I grab this instance and upload it's schema to the remote server? or is there a way to allow my project to create/destroy these tables in the fly like it does in my local machine?

I'll be honest, I'm not fully familiar with sessionstates, this is just what the tutorial had used to I guess create a session for shopping cart instances which are then 'stored' in temporary SQL instances/tables?... not sure if I should use 'InProc' or another option.

So I've decided to try and setup this reverted version on a free azure account (get free hosting for at least testing). I've managed to get rid of the SQL connection error by doing so, but now I need to migrate my object models into azure's database.

Is there a way to automatically add this stuff or is there some way I can create a .sql (or any schema xfer file) to then manually upload the tables/columns myself? ...the next option is to try and figure out how the models talk to each other and manually type out every column/table.

Sorry I keep changing up the scanrio, but I'm trying all angles I can think of... just about every time I post I increment versions so can always go back to a previous conversation.

Problem solved I guess. I just used Azure's interface to create a CartItems table with hard-coded columns... seems to work for now so I'll close this post. Thank you very much for the help and ideas!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.