简体   繁体   中英

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

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.

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. I used the command line instead:

  1. Download the MySql.Data.dll and put it in the same directory as the c# file

  2. Including the using directive at the top of the file:

using MySql.Data.MySqlClient;
  1. Run in the command line after getting to the directory:

csc FILENAME.cs /r:MySql.Data.dll

  1. Run in the command line

start FILENAME.exe

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM