gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-29 00:11:36 24 4
gpt4 key购买 nike

在我的一些学习项目中,我曾使用服务器资源管理器和相关工具通过 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com