convert C# to shared code

myndeswx

Client
Регистрация
15.05.2017
Сообщения
399
Благодарностей
88
Баллы
28
Hello, I am tired of using the same cube over and over in my template, and when one part changes I have to go over every cube to change it ...
Looking for someone who could make it work with shared code, so I could have everything in one place, and just call it as a function.

The code-
C#:
var result = string.Empty;
var command = new MySql.Data.MySqlClient.MySqlCommand();

command.CommandText = "SELECT * FROM `scrapers` WHERE captcha = 'false' and inuse = 'false' and hibernate = 'false'  ORDER BY RAND() LIMIT 1;";


var connectionString = "server=localhost;user=root;database=insta;port=3306;password=kobra;";
//var connectionString = "user id=root;persistsecurityinfo=True;database=mails;server=localhost;treatblobsasutf8=True;";

try
{
    command.Connection = new MySql.Data.MySqlClient.MySqlConnection(connectionString);
}
catch (Exception e)
{
    result =  "pizda su hardu";
}

if (result != String.Empty)
    
{
    return result;
}
    

try
    
{
command.Connection.Open();
    var read = command.ExecuteReader();
    while (read.Read())
        
    {
        
        project.Variables ["kokas"]. Value = read ["kokas"]. ToString ();
        project.Variables ["scraped"]. Value = read ["scraped"]. ToString ();
        project.Variables ["login"]. Value = read ["login"]. ToString ();

    
    
    
    }
}

catch (MySql.Data.MySqlClient.MySqlException e)
    
{
result = "pizda" + e.Message;
}

finally
    
{
command.Connection.Close ();
}

return result; [/ CODE]
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)