ARTICLE

Database Hosting on Shared Database Server in ASP.Net

Posted by Abhimanyu Kumar Vatsa Articles | ASP.NET using VB.NET June 04, 2010
This article will explain you, how to host MS-SQL Sever database on Shared Hosting Server.
Reader Level:

Introduction

In most of the cases we use to think, database hosting is very simple like as we host on our localhost. But remember, it is very different from localhost database hosting. We have lots of way to host the database on shared database server but this article will explain you the simplest way to work on Shared Database Hosting Sever.
 
Aim of the Article

In this article we will create a telephone directory on our localhost and then we will publish it to shared database sever that is to database provider.
 
Prerequisite

You should have the following things:

  1. VB 2005/2008, Visual Web Developer 2005/2008
  2. SQL Server Management Studio
  3. Microsoft SQL Server Database Publishing Wizard
Before getting started, install above all products successfully as in given order.

Creating Database in ASP.Net

At the very first, we have to create a web application which will display the telephone directory. Add New Item to our web application as named Default.aspx and select the Language as Visual Basic.

image1.gif


In above image, we can see our pages like Default.aspx, Default.aspx.vb, web.confi and a empty App_Data directory in the root of application. But we don't have any Database in App_Data directory, so let's create it.

To create database in ASP.Net, point the cursor in Database Explorer, right click on App_Data directory to Add New Item and in appeared window select SQL Database to create Database.mdf database file.

image2.gif


Now open point the cursor on Database Explorer, you can see here the added database. Now expand the Table option there, you will find nothing there because we have not added any table still. So, let's add new table to our web application.

To add new table in ASP.Net Database Explorer, right click on Table and select the Add New Table option. Now you will see the following screen with having any field.

image3.gif

Still we don't have any field there, let's add it as given in image below. Save this table using name 'telephone'.

image4.gif

Now we have a database and a table, you must like now to enter some data there. So, let's enter some data in database table.
To add data in table, right click on 'telephone' table in Database Explorer. It will show you the table and you have to enter some data for table. The image given below will explain you all about.

image5.gif

Now we have database, table and data also. You must now like to display data on web application form. Let's add it on form.

To add table's data on form simply drag the 'telephone' table from Database Explorer to application form. Here is a screenshot.

image6.gif

Now to view the actual data on form run the application. You will see the following data there.

image7.gif

Now we have everything complete on running on our localhost. The main issue is arising here, how to run it on Shared Database Severs? It is now very different from still we did. Let's step out towards Database Hosting on Shared Database Server.
 
I expect that you have installed all applications discussed above and running well on your localhost.

To publish database on hosting server, we have lots of way but the simple way I am mentioning. We have to create a query file on our localhost for our database and will be executed on Shared Database Server. Take a look at screenshot.

To create query file which has extension .sql, right click on 'Database.mdf' file in Database Explorer and now click on 'Publish to Provider' option.

image8.gif

Now follow the different screenshots to perform your task.

image9.gif

image10.gif

image11.gif

image12.gif

image13.gif

image14.gif

Now click on close button. Check in you hard disk drive which you will be given as script file location, there should be a 'database.sql' file. Let's take a look, how to publish it on Shared Database Server.
 
Note: Now internet connection required to open the remote database server.

To publish database file we have to execute the 'database.sql' file on shared database server. You should have your own credentials provided by your hosting company. Basically any hosting company serves many customers like you. They use to create database for you on your request. They use to decide that what will be the name of database file because they have to manage the database from hacking, virus or from any unauthorized usage. I am just showing you the way to execute using my own credentials and screenshots.

Now open an application named 'SQL Server Management Studio Express' as we have installed on above request, usually you will find this application under 'Microsoft SQL Server 2005/2008' in start menu. In appeared window type your own credentials. 'Sever Name' is usually an IP address, authentication will be as 'SQL Sever Authentication' and Login, Password and one more thing is database name will must have. At the end click on 'Connect' button.

image15.gif

It will take some time to map the location and verify the credentials provided by you. In the image given below you can see my database name as selected in left panel. There too databases but I have only authority for one which is selected.

image16.gif

Now click on 'New Query' option it will open you a new page. Open your 'database.sql' file in Notepad and copy the entire content and paste it there. Now click on 'Execute' option above to create the same database tables on shared database server.

  image17.gif

Now your database is also available on Shared Database Sever. You can use it on your application to run.

HAVE A HAPPY CODING !

Login to add your contents and source code to this article
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor