Free templates
Meny Search Free templates

INSERT INTO a MySQL database (C#, VB and ASP.NET) | Free code

Here you can download free code (C# and VB) to save data from a web form into (INSERT INTO) a table in a MySQL database.

Code for INSERT INTO a MySQL database allows you to let users on your web page to fill out forms with data that then is stored in a MySQL database located on a database server.

This code for saving data to a MySQL database is divided into two files, an aspx page that contains a web form to register as a user on a website and a codepage (C# or VB) that contains code for the SQL INSERT INTO statement. The web page with the web form is not connected to a "master page", a web project should contain a "master page" that is linked to CSS files so that it becomes easy to maintain the web design for the entire website.

Before you can save data to a MySQL database you must create the database and tables in the database and create a named connection string to the database in the "Web.config" file. In this template have we created a connection string to a MySQL database with the name of "ConnectionString" and this is the connection string that we make a reference to before we execute SQL statements.

The code for the INSERT INTO statement is surrounded by "Try/Catch/Finally" and this means that any errors in the code are handled by the web application, it is good to make sure that errors that can occur in the code not is handled by the web server that belongs to a web host. We catch "Sqlexceptions" in the "Catch" part and generate a user-friendly message when a specific exception occurs.

Remember that you in your web hosting account must have made a setting for the correct version of the "ASP.NET" version for your website (the version listed in the file "Web.config"). We are using Visual Web Developer 2005 (2010) Express Edition for web programming.
Updated: 01/01/2015 | Created by

Download INSERT INTO a MySQL database (C#, VB and ASP.NET) | Free code ยป

Tags: sql database code