Free templates
Meny Search Free templates

Connect to MySQL or MS SQL database (C#, VB and ASP.NET) | Free code

Here you can download free code (C# and VB) to connect a website to a MySQL or MS SQL database so that data can be stored in, retrieved from and updated in a database through SQL statements.

A database is an organized set of tables that are related to each other and a database is used in a web application to separate application code from data. The data in a database is organized in tables with fields in a way that makes it easy to add data, retrieve data and manipulate data.

Before a web application can connect to a MySQL database or a MS SQL database you must at first create the database in a database server or in a folder in your project. There is normally no difficulties in creating a database because this can be done with just a few clicks.

The code to connect to a MySQL or MS SQL database in ASP.NET is usually included in a file called "Web.config" and such a connection is given a name so that you can refer to that name in application code when you create SQL statements. To connect from a local computer to a SQL database that is located on a web host you must ensure that you have entered the IP number for your local computer in the settings for external database access at the web host.

An MS SQL database that is created in your own MS SQL server, in the "App_Data" folder in a web project for example, do normally not require a user name and a password (Windows authentication) in the connection string while a connection string to a database located on a web hosting service must include the name of the web server, the name of the database, username and password (SQL Authentication).

A connection to a MySQL database requires more work compared to a connection to a MS SQL database. If you want to connect to and use a MySQL database in a ASP.NET application then you need to install MySQL Connector Net for ASP.NET on your computer and/or your webserver to get the MySql.Data.dll file. If you have full control over the web server then it is enough to add a reference to MySql.Data.dll on the web server in your web project (the reference code will be added automatically to the web.config file). If you should host your website at a web hosting company then you need to include the MySql.Data.dll file in the "Bin" folder in your web project instead of just adding a reference to the file.

In the web.config file you can specify connections to multiple databases and each connection string should therefore have a unique name that you can refer to when you want to execute SQL commands against the specific database. We are using Visual Web Developer 2005 (2010) Express Edition for web programming.
Updated: 01-01-2015 | Created by All-templates.biz

Download Connect to MySQL or MS SQL database (C#, VB and ASP.NET) | Free code ยป

Tags: sql database code