MySQL ODBC 在 C# .NET 项目中失败,但在运行时编译的代码中失败

发布于 2024-09-07 22:37:51 字数 903 浏览 0 评论 0原文

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

<%@ 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 和上帝的意图创建 Web 应用程序的许多优势。

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

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

可能找不到与数据库的连接。我检查了存储在 Web.Config 文件中的连接字符串,以验证信息是否正确且正确。我在这里所做的事情有什么不同导致了我的失败?

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

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" %>

I've been using:

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

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.

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.

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

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?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

计㈡愣 2024-09-14 22:37:51

升级到 MySql ODBC 5.1 驱动程序似乎已经解决了该问题。刚刚安装了最新的驱动程序并将连接字符串从 3.51 更新到 5.1 和 viola,它起作用了。奇怪的原因——但是哦,好吧。我的目的不是问为什么......

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文