- Регистрация
- 06.05.2018
- Сообщения
- 57
- Благодарностей
- 1
- Баллы
- 8
Hello all,
I'm trying to do this video here:
I've followed it to a T I believe, even added the external assemblies and all.
I have the C# code going to a variable.
Thanks for any help, I've been looking through the forum and have seen many different examples on how to use Mysql database, but they don't help me because my knowledge is rather limited for now, and the examples here never really explain fully on how to do it.
I'm trying to do this video here:
I've followed it to a T I believe, even added the external assemblies and all.
Код:
var result = String.Empty;
var command = new MySql.Data.MySqlClient.MySqlCommand();
command.CommandText = "SELECT * FROM wpdatatable_17_2 ORDER BY RAND() LIMIT 1;";
var connectionSTring = "server=999.999.99.9;user=xxxxxx;database=xxxxxx;port=3306;password=xxxxxx;";
try
{
command.Connection = new MySql.Data.MySqlClient.MySqlConnection(connectionSTring);
}
catch (Exception e)
{
result = "Mysql error";
}
if (result!=String.Empty)
{
return result;
}
try
{
command.Connection.Open();
var read = command.ExecuteReader();
while (read.Read())
{
project.Variables["dmn"].Value = read["dmn"].ToString();
}
catch (MySql.Data.MySqlClient.MySqlException e)
{
result = "Mysql error "+e.Message;
}
finally
{
command.Connection.Close();
}
return result;
Thanks for any help, I've been looking through the forum and have seen many different examples on how to use Mysql database, but they don't help me because my knowledge is rather limited for now, and the examples here never really explain fully on how to do it.
Вложения
-
5,9 КБ Просмотры: 436