c# - Visual Studio Server Explorer 是否支持自定义数据库提供程序?

标签 c# mysql visual-studio oracle sqlite

在我的一些学习项目中,我曾使用服务器资源管理器和相关工具通过 Microsoft SQL Server 进行图形数据库开发 - 这是一次很棒的体验。然而,在我的工作中,我处理 Oracle DB 和 SQLite,我的业余项目使用 MySQL(因为它们托管在 Linux 上)。

有没有办法将 Visual Studio 中与数据库相关的工具与其他数据库提供程序结合使用?

最佳答案

以下是有关如何从 Visual Studio 连接到 MySQL 数据库的说明:

To make the connection in server explorer you need to do the following:

  • first of all you need to install the MyODBC connector 3.51 (or latest) on the development machine (NB. you can find this at http://www.mysql.com/products/connector/odbc/ )

  • Create a datasource in Control Panel/Administrative Tools with a connection to your database. This data source is going to be used purely for Server Manager and you dont need to worry about creating the same data source on your clients PC when you have made your VS.NET application (Unless you want to) - I dont want to cover this in this answer, too long. For the purpose of this explanation I will pretend that you created a MyODBC data source called 'AADSN' to database 'noddy' on mysqlserver 'SERVER01' and have a root password of 'fred'. The server can be either the Computer Name (found in Control Panel/System/Computer Name), or alternatively it can be the IP Address. NB. Make sure that you test this connection before continuing with this explanation.

  • open your VS.NET project

  • go to server explorer

  • right-click on 'Data Connections'

  • select 'Add Connection'

  • In DataLink Properties, go to the provider tab and select "Microsoft OLE DB Provider For ODBC drivers"

  • Click Next

  • If you previously created an ODBC data source then you could just select that. The disadvantage of this is that when you install your project application on the client machine, the same data source needs to be there. I prefer to use a connection string. This should look something like:

DSN=AADSN;DESC=MySQL ODBC 3.51 Driver DSN;DATABASE=noddy;SERVER=SERVER01;UID=root;PASSWORD=fred;PORT=3306;SOCKET=;OPTION=11;STMT=;

If you omit the password from the connection string then you must make sure that the datasource you created (AADSN) contains a password. I am not going to describe what these mean, you can look in the documentation for myodbc for that, just ensure that you get a "Connection Succeeded" message when you test the datasource.

关于c# - Visual Studio Server Explorer 是否支持自定义数据库提供程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31885/

相关文章:

c# - Thread.Interrupt 不工作

c# - Windows 8 应用程序中的屏幕分辨率检测

mysql - Ubuntu 中的 Memsql 和 MySql 安装

mysql - HQL 中的自引用更新

visual-studio - 如何制作 F# 的类图?

c# - 为什么调试包括外部库代码

c# - WPF/XAML 将元素的宽度绑定(bind)到屏幕大小的一部分

java - 尝试将工作的现有 java 类复制到 servlet 中,com.mysql.jdbc.Driver 错误

C# 根据使用的 dll 版本编译函数。

c# - 如何在C#中从控件的字符串名称获取对控件的引用