这里我想在gridview
数据库的mysql
中显示员工表通知
CODE
OdbcConnection con = new OdbcConnection("Driver={MySQL ODBC 3.51 ANSI Driver};Server=localhost;Database=test;uid=root;pwd=amritalikun;option=3");
OdbcCommand cmd;
OdbcDataReader rr;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
cmd = con.CreateCommand();
cmd.CommandText = "select * from employee";
con.Open();
rr = cmd.ExecuteReader();
GridView1.DataSource = rr;
GridView1.DataBind();
con.Close();
}
问题是每当我调试我的代码时,它会在con.Open()行
显示以下错误 An exception of type System.Data.Odbc.OdbcException occurred in System.Data.dll but was not handled in user code
Additional information: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
我实际上并没有得到什么错误,需要帮助解决这个问题。!!
答案 0 :(得分:0)
您需要为 MySQL ODBC 3.51
安装适当的驱动程序去运行并键入odbcad32.exe然后转到系统DSN并检查是否 是否安装了MySQL ODBC 3.51驱动程序