Wednesday, November 19, 2008

Connecting MySql With Using ODBC Drivers

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


A more supported format for connecting to MySQL from a C# .NET web application is by using the common ODBC driver. First, you will need to install the MySQL ODBC driver on your PC. This same driver (MyODBC) is usually installed on most web servers. As such, you may have no other choice except to use ODBC for connecting to MySQL.

Connecting to the MySQL database from your C# ASP .NET web application using ODBC is very similar to the above example. You just change a small part of each command definition from MySQL to Odbc.

using System.Data;

using System.Data.Odbc;

public partial class odbc : System.Web.UI.Page


static string s = "driver={Mysql odbc 3.51 driver}; sever =localhost; user id=root;password=admin;database=temp;option=3";

OdbcConnection con = new OdbcConnection(s);

protected void Page_Load(object sender, EventArgs e)


OdbcDataAdapter da = new OdbcDataAdapter("select * from emp", con);

DataSet ds = new DataSet();

da.Fill(ds, "emp");

GridView1.DataSource = ds;




Your Ad Here


Respects for your's Questions & Opinions

  • Friends

    Recent Posts

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