MySQL ODBC在C#.NET项目中失败,但在运行时编译的代码中失败 [英] MySQL ODBC fails in C# .NET project but not runtime compiled code

查看:38
本文介绍了MySQL ODBC在C#.NET项目中失败,但在运行时编译的代码中失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,通过MySql ODBC驱动程序3.51访问Web服务器上的MySql数据库.到目前为止,我一直坚持在记事本中编写此Web应用程序的ASP.NET C#代码,而仅在服务器端使用运行时编译来操作所有内容.因此,不要使用类似的东西:

I have a project in which I'm accessing a MySql database on my web server via MySql ODBC driver 3.51. So far I've stuck to writing the ASP.NET C# code for this web app in notepad and just using runtime compiles on the server side to operate everything. So instead of using something like:

<%@ Page Title="Add Order" Language="C#" MasterPageFile="~/main_layout.Master" AutoEventWireup="true" CodeBehind="order_add.aspx.cs" Inherits="Orders.order_add" %>

我一直在使用:

<script language="c#" runat="server" src="cs/orders.cs"></script>

在页面标题中的

,用于加载C#代码以访问数据库.那很快就变成了管理的负担,我看到了按照Microsoft和God的意图创建Web应用程序的众多优势.

within the header of the page to load the C# code to access the database. That was quickly becoming a bear to manage and I see numerous advantages to creating my web application the way Microsoft and God intended.

但是当我使用完全相同的代码并将其从以前的工作中提取出来并放入Visual Studio 2010(Express)中时,会出现连接错误.

But when I take the exact same code and pull it from my previous work and put it into Visual Studio 2010 (Express) I get a connection error.

错误[IM002] [Microsoft] [ODBC驱动程序管理器]找不到数据源名称,并且未指定默认驱动程序

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

大概它找不到与数据库的连接.我已经检查了存储在Web.Config文件中的连接字符串,以验证信息正确无误.造成失败的原因与我在这里所做的有什么区别?

Presumably it can't find the connection to the database. I've checked the connection string, stored in the Web.Config file, to validate that the information is correct and it's spot on. What is the difference in what I'm doing here that is causing my failure?

其他说明:这是Windows 7 64bit上的MySql 3.51 ODBC驱动程序,Microsoft Visual Web Developer 2010 Express

Other notes: this is the MySql 3.51 ODBC Driver on Windows 7 64bit, Microsoft Visual Web Developer 2010 Express

推荐答案

升级到MySql ODBC 5.1驱动程序似乎已解决了该问题.只需安装最新的驱动程序并将连接字符串从3.51更新为5.1和中提琴,它就可以正常工作.奇怪的原因-但是哦.我不是在问为什么...

Upgrading to MySql ODBC 5.1 Driver seems to have fixed the issue. Just installed the latest driver and updated the connection string from 3.51 to 5.1 and viola, it worked. Odd why - but oh well. Mine is not to question why...

这篇关于MySQL ODBC在C#.NET项目中失败,但在运行时编译的代码中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆