Connection String Noob issue: given this, now what?

Discussion in 'Databases' started by PJ2010, Mar 3, 2010.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. This should be easy to answer. I just signed up for SQL Server 2008 as an add on. Now I want to change my Connection String (ASP.NET, built under Visual Studio 2008 express, running fine on my localhost HD under SQL Server 2008 Express).

    How do I migrate this database--which BTW resides on the same folder that the Default.aspx page of my ASP.NET application--onto the discountasp.net SQL Server 2008 engine that I bought?

    Any replies greatly appreciated. DiscountASP.net recommended string in BLUE color, my present connection string (which works fine locally) in MAGENTA color.

    PJ

    Recommended by discountASP.net:

    QL Server Name sql2k803.discountasp.net
    Database Name SQL2008_709539
    Database Space
    500 MB (Add SQL Disk Space)
    Database Login SQL2008_709539_user
    SQL Web Admin https://sqlwebadmin.discountasp.net (powered by myLittleAdmin)
    SQL Usage Meter
    Connection String "Data Source=tcp:sql2k803.discountasp.net;Initial Catalog=SQL2008_709539;User ID=SQL2008_709539_user;Password=******;"
    KB Articles KB ID:186: How to connect to SQL Server 2008 using SQL Server Management Studio? (I read this and it does not help--this goes to the issue of when you are designing a database, what to do if you want to connect remotely to a database found at discountasp.net. What I want is to migrate a local database onto the discountasp.net database engine I just bought--PJ)


    "Data Source=tcp:sql2k803.discountasp.net;Initial Catalog=SQL2008_709539;User ID=SQL2008_709539_user;Password=******;"


    //from Web.config file of my ASP.NET program (works fine on localhost, using SQL Server 2008 Express):

    <connectionStrings>
    <add name="FolktaleDBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=&quot;|DataDirectory|FolktaleDB2b.mdf&quot;;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient"/>
    </connectionStrings>
     
  2. dmitri

    dmitri DiscountASP.NET Staff

    The most popular methods to publish your local database to discountASP.NET database servers are:

    1. Detach / Attach
    2. Backup / Restore

    The first method - Detach / Attach - is easier, so I would recommend to try it first. The general steps for this method are as follows:

    1. Detach your local database
    2. Copy .mdf file of your database to your site
    3. Use SQL Management Tools provided to you in the control panel to attach this file to your database on the server

    Please refere to this KB article for the detailed instructions.

    Please note, .mdf is not a regular file which you can just copy to another location. Before copying it, your database has to be detached. If not properly detached, you will not be able to attach it on the server. After attaching process is done, you can go ahead and delete .mdf file which you uploaded to the web server since it was copied to a different location.

    When done attaching, open your web.config file and replace your local connection string in magenta with your server's connection string with blue. You new web.config entry should look like this:

    <add name="FolktaleDBConnectionString" "Data Source=tcp:sql2k803.discountasp.net;Initial Catalog=SQL2008_709539;User ID=SQL2008_709539_user;Password=******;"/>

    Replace ******* with your actual password
     
  3. A miracle. It worked the first time.

    dmitri—wow, thanks a million. I’m in state of shock. It worked perfectly the first time, following exactly your instructions for “Detach/Attach”. That is so rare in programming.

    Just for my records, here is what was replaced in the Web.config file of ASP.NET after took the steps you outlined, and detached/attached using the SQL Management Tool in the control panel:

    //ORIGINAL
    <connectionStrings>
    <add name="FolktaleDBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=&quot;|DataDirectory|FolktaleDB2b.mdf&quot;;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient"/>



    //REPLACEMENT
    <connectionStrings>
    <add name="FolktaleDBConnectionString" connectionString="Data Source=tcp:sql2k803.discountasp.net; Initial Catalog=SQL2008_709539;User ID=SQL2008_709539_user;Password=###############;"/>
    </connectionStrings>


    I am amazed that leaving out the extra information from the original connection string did not throw an exception. Unreal.

    If it’s not against house rules, send me an email here with a mailing address: pljprogrammer_AT_live.com and I’ll send you some worthless Greek coins (drachmas—they became worthless when GR joined the euro in 1999, but who knows, the way things are going they might come back).

    I still can’t believe it worked out so well… awesome.

    Also it appears that at discountasp.net you’re only allowed one instance of SQL Server 2008 for every $10 a month you pay (“You currently have 1 MS SQL 2008 Server service(s) activated on your account. An additional MS SQL Server 2008 can be added to your account as an addon. You can add up to 5 SQL 2008 Databases to a single hosting account.”). So I either have to overwrite this database every time (if I’m just testing) or pay $10 / mo. for each additional instance. Sounds reasonable.

    Thanks again. Incredible. This place is great

    PJ
     
  4. dmitri

    dmitri DiscountASP.NET Staff

    I am glad it worked first time without any struggle. Thank you for your compliments and praises. We appreciate it. The control panel which allows you to do this with ease was built in house and is really a pride of our company.

    The original connection string contained parameters that were related to your local environment and needed to be removed.

    It is sad that drachmas becomes worthless. Well, at least silver coins drachmas will never be worthless. What is the oldest one you have ever hold?
     
  5. Nice work. The company is a cut above the competition that's for sure. I only found out from another member, word of mouth, at Channel 9 at MSDN. Maybe you should advertise more? So many firms out there are just plain vanilla web hosting; this is like heaven compared to before (I was using a corporate IT guy in the US who was learning as he went--took him forever to do anything...after three months of bugging him we finally got a Silverlight app uploaded, the simplest possible app, as you only need to upload your TestPage.html and your .xap file, and you're done, but it still took him ages to set up a directory, etc.)

    I see. But I still would have thought an exception would have been thrown. Tx for the advice. Made my day. Now onto web services (using Silverlight). I see you even have a forum for that.

    1960. The ancient Greek drachma, which was silver because silver is found near Athens in relative abundance, is a collectible I've never had the pleasure of holding. But counterfeits abound. There's a bunch of silver and gold guys who sell near the Monestiraki metro stop, facing the Acropolis, out in the street, but they are of varying degrees of honesty so I just buy bullion coins off them, not rare collectibles. And the cheapest priced bullion coins are sold in the USA. They do have in Greece some nice looking bills (paper money) which went worthless but look good when framed (Greece has a storied history of financial defaults; the latest is just one of a series).

    PJ
     
  6. dmitri

    dmitri DiscountASP.NET Staff

    Thank you again for your positive comments; we are pleased to hear them.
    Do you think so? I thought that we are being advertised too much. Try to type some asp.net hosting related keywords in google and you will probably see us on top: courtesy of our marketing team.

    It is sad that after more then 2K5 years of existence drachma became obsolete. Well, things may change back, who knows...
    [​IMG]
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page