0% found this document useful (0 votes)
38 views5 pages

Notes On Publishing Your CO5027 Website If You Haven't Worked From Scratch With A Live SQL Database

The document provides instructions for publishing a website with a database to a live SQL server if it was originally developed using a local database in Visual Studio. It involves 5 main steps: 1. Creating a live SQL database on the school server to hold the database tables 2. Activating the folder for the website on the school server 3. Using SQL tools to export the database tables from the local database and import them into the live SQL database 4. Modifying the website's web.config file to connect to the live SQL database instead of the local one 5. Uploading the website files to the live folder on the school server and testing
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views5 pages

Notes On Publishing Your CO5027 Website If You Haven't Worked From Scratch With A Live SQL Database

The document provides instructions for publishing a website with a database to a live SQL server if it was originally developed using a local database in Visual Studio. It involves 5 main steps: 1. Creating a live SQL database on the school server to hold the database tables 2. Activating the folder for the website on the school server 3. Using SQL tools to export the database tables from the local database and import them into the live SQL database 4. Modifying the website's web.config file to connect to the live SQL database instead of the local one 5. Uploading the website files to the live folder on the school server and testing
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Notes on publishing your CO5027 website if you haven’t worked from

scratch with a live SQL database


Assumptions
 You have a website with a database for providing some of your content, e.g. database.mdf in
the App_Data folder
 You have used the default ASP.NET security method for login – you should see a database
called aspnetdb.mdf in the App_Data folder.
 Your site works fine from within Visual Studio 2008 when you hit play - i.e. you can see all
your pages with data content and you can login.

If any of the above don’t apply you will need to verify your web site is correct with your tutor.

Stages
1. Create a live SQL database ready to receive your existing databases.
2. Activate your CO5027 folder on the web server.
3. Copy your databases over to the live SQL server database.
4. Modify your websites web.config file to work with the live SQL database and test it from
your desktop.
5. Copy the website into the CO5027 folder in your webspace and test it from there.

1. Creating a live SQL database


a) Go to http://compsci.chester.ac.uk/csisnetwork
b) Select ‘Creating SQL Databases’ and login with your csis\studid account (same as remote
desktop).
c) Add a new database for your web site, e.g.

d) Note down the details for later, e.g.


2. Activate your CO5027 folder on the web server
a) From the csisnetwork site in stage 1a choose ‘Managing ASP.NET applications’. You may
need to log in again if you closed your browser after stage 1.
b) Type CO5027 into the application name, e.g.

c) You should now get your application listed as follows:

3. Copy your databases over to the live SQL database


If you are working at home with VS2008 you can download the Microsoft SQL Database Publishing
Wizard and install it – it will allow you to use VS2008 for this stage. If you are working in our labs in
University you will need to use VS2010 as it is the only version with the SQL publishing wizard
installed.

a) Work from a copy of your website – just in case.


b) Run VS2010 and open your website. Make sure you do NOT convert it to ASP.NET v4.0 when
prompted.
c) View | Server Explorer
d) Right click your content database (e.g. database.mdf) and choose ‘Publish to provider …’
e) Follow the wizard stage to create an SQL file called database.mdf.sql in your Documents
folder.
f) Right click your security database (e.g. asmpnetdb.mdf) and choose ‘Publish to provider …’
g) Follow the wizard stage to create an SQL file called aspnetdb.mdf.sql in your Documents
folder.
h) Run Microsoft SQL Management Studio and login with the details from stage 1, e.g.
i) Open the Databases folder and select your database e.g.

j) Right click your database and choose New Query. An SQL Query window will open. Keep SQL
Management Studio open for the rest of this stage.
k) Using Windows Explorer, find the SQL file from step e) and open it with Notepad.
l) Select all the SQL statements and copy them to the clipboard (Ctrl-A and Ctrl-C).
m) Switch to SQL Management Studio and paste the SQL into the SQL Query window.
n) Click the Execute button. The SQL query should run and show one or more messages saying
something like ‘1 record affected’.
o) Clear the SQL Query window and repeat steps k) to n) for the SQL file from step g)
p) Your databases have now been published to your live SQL database and you can close SQL
Management Studio – you don’t need to save the Query.

4. Modify your websites web.config file


a) Switch back to VS2010 and open your web.config file. Locate the <connectionStrings>
section. It should look like this:
<connectionStrings>
<add name="ConnectionString" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=|
DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
a) Delete the contents of the connectionString attribute:
<connectionStrings>
<add name="ConnectionString" connectionString=""
providerName="System.Data.SqlClient" />
</connectionStrings>
b) Replace it with:
"Data Source=mssql.compsci.chester.ac.uk;
Initial Catalog=yourdatabasename;
User ID=yourdbusername;
Password=yourpassword"
Note: the string should be all on one line – watch out for spaces! E.g.
<connectionStrings>
<add name="ConnectionString"
connectionString="Data Source=mssql.compsci.chester.ac.uk;
Initial Catalog=db_0000000_co5027;
User ID=user_db_0000000_co5027;
Password=P@55word"
providerName="System.Data.SqlClient" />
</connectionStrings>
c) Now you need to add and an extra connection string for the security database, but you need
to add a statement to remove the default one first. Immediately after the
<connectionStrings> tag add the following lines, using your own database name, username
and password, e.g.
<remove name="LocalSqlServer" />
<add name="LocalSqlServer"
connectionString="Data Source=mssql.compsci.chester.ac.uk;
Initial Catalog=db_0000000_co5027;
User ID=user_db_0000000_co5027;
Password=P@55word"
providerName="System.Data.SqlClient" />

d) Now add the following lines immediately after the <system.web> tag:
<membership defaultProvider="RemoteSqlProvider">
<providers>
<clear/>
<add name="RemoteSqlProvider"
connectionStringName="LocalSqlServer"
enablePasswordRetrieval="true"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
applicationName="/"
requiresUniqueEmail="false"
passwordFormat="Encrypted"
maxInvalidPasswordAttempts="3"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""
type="System.Web.Security.SqlMembershipProvider,
System.Web,Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</membership>
e) Save your web config file and run your website. It should work properly. You should be able
to see your data on your pages and you should be able to login.

5.Upload your site and test it


Copy the entire contents of your website folder into the CO5027 folder on your web space. You can
use Remote Desktop to access your web space using drive W:

You may delete the App_Data folder on your web space as the local databases aren’t needed on the
live site.

Warning: Don’t delete the CO5027 folder on W: - your web space will stop working even if you
recreate it.

You might also like