Answer the question
In order to leave comments, you need to log in
How to connect to db from c# via ssh?
Hello! How to connect from c# to Mysql, which is running on a server that can only be accessed via SSH? It's just that I can connect through PuTTY, I can make requests and receive signs. Should I use the
Tamir.SharpSsh library? it turns out from the program code to send requests and receive answers, but the format of the answer does not get tired. It would be nice to receive in the form of a DataTable. Screenshot of the table format, if you use the Tamir.SharpSsh lib:
All code is written in the format (this is how everything worked until we moved from localhost to a remote server):
DataTable dt = new DataTable();
MySqlConnectionStringBuilder mysqlCSB;
mysqlCSB = new MySqlConnectionStringBuilder();
mysqlCSB.Server = "адрес сервера";
mysqlCSB.Database = "имя бдшки";
mysqlCSB.UserID = user;
mysqlCSB.Password = pass;
mysqlCSB.Port = 3306;
string queryString = @"SELECT * FROM articles;";
using (MySqlConnection con = new MySqlConnection())
{
con.ConnectionString = mysqlCSB.ConnectionString;
MySqlCommand com = new MySqlCommand(queryString, con);
try
{
con.Open();
using (MySqlDataReader dr = com.ExecuteReader())
{
if (dr.HasRows)
{
dt.Load(dr);
Console.WriteLine("ok");
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
Answer the question
In order to leave comments, you need to log in
man ssh /-R.
Well, there is no normal implementation of openssh under C#.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question