Internosis - knowledge management,ecommerce and project consulting
*Home>>>Application Development

How to access a database on anothe server in vb.net?


I am working on a project where I am building a custome Web application to access a SQL database. Right now I am running the database and the web application all off one machine for development. And I use the SqlClient Name Space to access my SQl database. I was wondering how I am going to access the database once the web site is up and running because I will no be running the database off the same server as my website. The database will be on a server at my office location while my application will be hosted on some web server provider. What kinda of connection string will I need to have. Right now its just a string to my C:\.... where my SQL database is. The app is on a different server how will I change up my connection string? Is there any good books on that actually show you how to implement the project on a web server and how to connect to a dataabase on a different servers?

your connection string should stay close to the same. the difference should be instead of c:/... it would be the machine address or name. also you would include the login/pass with the connection string. its very simple. link below help with connection strings

Not the best of setups I would say...

All you really need to do is to change the connection string. However, it does not end there... You need to configure your server to accept connections from the internet.

How to connect to SQL Server over Internet
http://msdn2.microsoft.com/en-gb/library...
http://msdn2.microsoft.com/en-us/library...

Connecting to your SQL Server over the internet has the following problems:

1) Connectivity - before we go any further... your office server needs to have a global IP address. You can easily get one though, but you will need to beef up security and set up firewalls and stuff....

2) Security -You need to open up various ports on your firewall which could pose a threat.

3) Connectivity - Unless your website does not really need to get lots of data from the database... you willl need a reasonably fast internet connection.

A better option is to use one of the millions of hosting providers that allow .NET and SQL Server databases. I am actually quite sure your hosting provider would provide SQL Server if they are providing ASP.NET.

If on the other hand your main concern is that you want to update the website database with data from the office in real time, then I would suggest database replication. You could also write a small application that sends database updates to the website database using web services or something.

You should NEVER hardcode your ConnectionString!!!
Add the Connection String to your web.config like this:
<configuration>
<appSettings>
<add key="DefaultSQLConnection" value="server=YouServerName;
DataBase=YourDBNameuid=sa;pwd=;" />
</appSettings>
</Configuration>

In your code whenever you need to create a new SqlConnection object you use the following code
//VB.NET

ConnectionString = System.Configuration.ConfigurationSettin...
AppSettings("DefaultSqlConnection")
'Now create your SqlConnection object based on the ConnectionString read from web.config
//C# code
string connString = System.Configuration.ConfigurationSettin...
AppSettings["DefaultSQLConnection"];
SqlConnection cn = new SqlConnection(connString);
//use your connection here

Note: Whenever your connection string changes, you simply change it in the centralized location i.e. in your web.config file. This way you do not have to follow all the hardcoded connection strings and recompile your application.

Tags
  E-Commerce   Supply Chain   Data Mining   ERP   CRM   Application Development   Software Consulting   Software Development   Information Technology   Technology Consulting   Project Training
Related information
  • How can a UXD / UI designer assess the back-end effort involved when designing front-end functionality?

    Well, MySQL can handle lots of information and still be fast. It works well with PHP, and PHP is easy to learn and code. You probobly want a good control panel for coding and management. I recomend...

  • Questions abt ceramics??

    1) Aluminum oxide 2) insulators for electricity, insulators for heat(ceramic furnace linings, the tiles on the space shuttle),abrasion resistance (floor tiles, flame or arc tips on welding machine...

  • Planning permission?

    I think that it is a legal requirement to post notices near the development site, as at the moment nearby where i live there is a large development underway and they have posted a notice of plannin...

  • Online messaging for websites?

    If you intend for the installable application to be very widely used, you should probably write it in c++. However, it is MUCH easier to write it in a managed language/framework like c# or VB.NET. ...

  • What tool was used to design the Windows Media Player GUI?

    The UI in WMP could easily be mimicked in VB.NET - it is mainly a matter of having a talented graphics and UI designer who can create the graphic elements for you. Once those have been created, it ...

  • I receive this mail everyday. What should I do?

    Whats that all about:...............

    ...
  • How can i get my house back which is in my wifes name but the loan is in my name.?

    Choubey ji aap se ye umid nahi thee. You being a senior level officer in a Company are supposed to be having this legal awareness that any property you apply in name of any person will get register...

  • How can i be relieved of bank loan ,without loss of property purchased in my wifes name in divorced case?

    It is very very critical case. Better go and consult a good lawyer and then take a decision. Without any legal background this case is very difficult to handle. Please do not believe any body'...

  •  

    Categories--Copyright/IP Policy--Contact Webmaster