首页 新闻 搜索 专区 学院

.net连接mysql报错

0
悬赏园豆:20 [已关闭问题]
<h2><em>[DBNETLIB][ConnectionOpen (Connect()).]SQL Server 不存在或拒绝访问。</em> </h2> <p><span style="font-family: Arial, Helvetica, Geneva, SunSans-Regular, sans-serif;"><strong>说明: </strong>执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 <br /><br /><strong>异常详细信息: </strong>System.Data.OleDb.OleDbException: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server 不存在或拒绝访问。<br /><br /><strong>源错误:</strong> <br /><br /></span></p> <table style="width: 100%;" bgcolor="#ffffcc"> <tbody> <tr> <td><code> <pre>行 26: 行 27: OleDbConnection con = createCone();<span style="color: red;">行 28: con.Open();</span>行 29: OleDbDataAdapter sda = new OleDbDataAdapter(sql, con);行 30: DataSet ds = new DataSet();</pre> </code></td> </tr> </tbody> </table> <p>public class dataOperate<br />{<br />&nbsp;&nbsp;&nbsp; public static OleDbConnection createCone()<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OleDbConnection con = new OleDbConnection("Provider=SQLOLEDB;Data Source=test;User Id=root;Password=123");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return con;<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; public static DataSet getDataset(string sql, string table)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OleDbConnection con = createCone();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; con.Open();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OleDbDataAdapter sda = new OleDbDataAdapter(sql, con);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataSet ds = new DataSet();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sda.Fill(ds, table);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ds;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; con.Close();<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;<br />}</p>
liuchangfei的主页 liuchangfei | 初学一级 | 园豆:45
提问于:2010-06-07 10:12
< >
分享
其他回答(1)
0

连接串有误!

http://www.connectionstrings.com/mysql

邀月 | 园豆:25375 (高人七级) | 2010-06-07 10:28
0

Data Source=localhost;database=;user id=root;password=

最初的模样 | 园豆:198 (初学一级) | 2010-06-16 20:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册