[英]How do you connect C# to a remote MySQL Server in Atom?
I am using C# 5 on Windows in the Atom IDE with the script package.我在 Atom IDE 的 Windows 上使用 C# 5 和脚本 ZEFE90A8E604A37C840D8ZF0。 In order to connect to a PHPMyAdmin MySQL database server, I need the mysql.data
namespace, but without Visual Studio, I do not know how to include this assembly reference.为了连接到 PHPMyAdmin MySQL 数据库服务器,我需要mysql.data
命名空间,但没有 Visual Studio,我不知道如何包含此程序集引用。
String server = "localhost";
String database = "connectcsharptomysql";
String uid = "username";
String password = "password";
String connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection s = new MySqlConnection(connectionString);
I have viewed these posts but they all concern using Visual Studio or a problem with the connection itself.我已经查看了这些帖子,但它们都涉及使用 Visual Studio 或连接本身的问题。
I was not able to do it in Atom because even though I added the assembly I don't know how to reference it within the IDE.我无法在 Atom 中执行此操作,因为即使我添加了程序集,我也不知道如何在 IDE 中引用它。 I used the command line instead:我改用命令行:
Download the MySql.Data.dll and put it in the same directory as the c# file下载 MySql.Data.dll 并将其放在与 c# 文件相同的目录下
Including the using
directive at the top of the file:在文件顶部包括using
指令:
using MySql.Data.MySqlClient;
csc FILENAME.cs /r:MySql.Data.dll csc 文件名.cs /r:MySql.Data.dll
start FILENAME.exe启动文件名.exe
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.