usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;//...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//using System.Data.Odbc;
using System.Data.SqlClient;
using System.Data.Common;
using System.Data.OleDb;
using Microsoft.Data.Odbc;
上面是头文件
下面是连接部分
string strconn ="DRIVER={MySQLODBC3.51Driver};"+ "SERVER=localhost;"+ "DATABASE=rmdb;"+ "UID=root;"+ "PASSWORD=root;"+ "OPTION=3";
string sql = "select * from staffmsg";
OdbcConnection con = new OdbcConnection(strconn);
OdbcCommand mycommand = new OdbcCommand(sql, con);
try
{
con.Open();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
}
http://www.csharpwin.com/csharpspace/6864r4050.shtml我按这个网址上所说去配置好了所有该配置的,编译没问题,可是一运行,就会弹出错误信息:
未发现数据源名称并且未指定默认驱动程序
能不能指出错误地方,并提供解决方案!
主要我们是学生,小组定下这个规定,就用ODBC,我也不好去劝说别人,所以就ODBC,希望会的回答,不要叫改什么比较方便,我想学点!
展开