Thursday, November 6, 2008

Connecting MySql With C# ASP.NET

0 comments 11/06/2008
Sign up to receive our site updates!

Introduction
If you're creating a web application using C# ASP .NET, you will more than likely be using one of the three top database engines MySQL, MSSQL (Microsoft SQL Server), or Oracle to store your online data. From the developer's view, all three databases are virtually the same. You use the same generic framework calls to connect, read, and write data. While it is more common to use Microsoft's MSSQL Server with a .NET application, a large number of web hosts offer the free MySQL database. Therefore, connecting to a MySQL database from C# ASP .NET is an important task and is actually quite easy to do.
Using MySQL with C# ASP .NET
MySQL is a free database and is used very heavily by the linux developers usually when programming with Perl, CGI, or Ruby on Rails. Because of this, MySQL is, for the most part, catered and optimized directly towards the linux developing platform. However, using MySQL from a Windows web application is also supported and MySQL offers several drivers just for Windows users.
The actual library you choose to connect to the database from C# ASP .NET can make a huge impact on the speed and reliability of your database transactions. In addition, your web server may only be configured to use a specific database library from within C#. Choosing the correct database library to use is an important decision in your web application design.
MySQL and MySQLDriverCS
MySQLDriverCS http://sourceforge.net/projects/mysqldrivercs is a free driver framework for connecting to MySQL from within a C# ASP .NET application. It uses the ADO .NET framework. To use it, you simply include a reference to MySQLDriverCS.dll(In program Files in setup folder of MYSQLDRIVERCS) from within your C# .NET application and include the file libMySQL.dll within your /bin folder. Below is an example of using MySQLDriverCS to connect to a MySQL database.
using MySQLDriverCS;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MySQLConnection myConn;
myConn = new MySQLConnection(new MySQLConnectionString("localhost", "databse", "User", "password").AsString);
MySQLDataAdapter da = new MySQLDataAdapter("select * from dental", myConn);
DataSet ds = new DataSet();
da.Fill(ds, "raji");
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
Your Ad Here

0 comments:

Respects for your's Questions & Opinions

  • Friends
  •  

    Recent Posts

    New Comments

    Copyright 2008 All Rights Reserved Tech Tasks Template by Rajesh Kumar Chekuri