Subscribe
TechTasks.net

The Blog is Moved to www.TechTasks.net

Connecting MySql With Asp.net Using ODBC Drivers

Posted by Rajesh Kumar Chekuri on

MySQL and ODBC

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 http://www.mysql.com/products/connector/odbc 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.

Thanks for Visiting www.funnydotnet.co.cc


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;

GridView1.DataBind();

}

}





Bookmark and Share
Connecting MySql With Asp.net Using ODBC DriversSocialTwist Tell-a-Friend

1 comments:

Anonymous said...

Hi guys, my names Eva and im completely new to this forum.

I hope that I'll learn and share a lot of interesting things.

Thanks,
Eva

Subscribe to: Post Comments (Atom)
Thanks For Visiting