Tuesday, 15 March 2011

How To Connect MySql Databse With Asp.net

Download the exe file from this http://dev.mysql.com/downloads/connector/odbc/3.51.html
for the MySQL ODBC 3.51 Driver
may be you have to register this site for download the exe.

After run the exe try this code :
--------------------------------------
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.Odbc;


public partial class _Default : System.Web.UI.Page
{
    string sConString = "Driver={MySQL ODBC 3.51 Driver};" + "Server=localhost;" + "Database=test;" + "user id=;" + "password=";
    OdbcConnection oConnection = new OdbcConnection(sConString);
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (oConnection.State != ConnectionState.Open)
            {
                oConnection.Open();
            }
        }
        catch
        {
        }
        finally
        {
            oConnection.Close();
        }

    }
}
------------------

1 comment:

Get all non-clustered indexes

DECLARE cIX CURSOR FOR     SELECT OBJECT_NAME(SI.Object_ID), SI.Object_ID, SI.Name, SI.Index_ID         FROM Sys.Indexes SI             ...