vs odbc mysql_VS中C#中用ODBC访问MYSQL数据库问题

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,希望会的回答,不要叫改什么比较方便,我想学点!

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值