Hi all. this is the first time i have messed around with mysql, all i have is a headache. i'm using mysql 4.0.18 with ODBC driver 3.5 and using ASP.NET with C# to retreive data. i was just wondering if someone could help me connect to my Database. this is what i have so far.
<%@ Page Language="C#" AutoEventWireup="False"
EnableSessionState="False" EnableViewState="False" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Odbc" %>
<script runat="server">
private const string ConnStr = "Driver={MySQL ODBC 3.51 Driver};" +
"Server=localhost;Database=test;uid=root;pwd=yourp assword;option=3";
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
using(OdbcConnection con = new OdbcConnection(ConnStr))
using(OdbcCommand cmd = new OdbcCommand("SELECT * FROM Names", con))
{
con.Open();
dgrAllNames.DataSource = cmd.ExecuteReader(
CommandBehavior.CloseConnection |
CommandBehavior.SingleResult);
dgrAllNames.DataBind();
}
}
</script>
Is this right?