Подскажите плиз как сделать инсерт нескольких строк?
одну строку добавляю так:
var result = string.Empty;
var command = new MySql.Data.MySqlClient.MySqlCommand();
var connectionString = "";
try
{
command.Connection = new MySql.Data.MySqlClient.MySqlConnection(connectionString);
}
catch (Exception e)
{
result = "Musql error connection";
}
if (result!=String.Empty)
{
return result;
}
try
{
command.Connection.Open();
string request = "INSERT INTO `out` (column1, column2) VALUES (@site, @id)";
MySql.Data.MySqlClient.MySqlCommand com = new MySql.Data.MySqlClient.MySqlCommand(request, command.Connection);
com.Parameters.AddWithValue("@site", "url1");
com.Parameters.AddWithValue("@id", "id1");
com.ExecuteNonQuery();
}
catch (MySql.Data.MySqlClient.MySqlException e)
{
result = "Mysql error2"+e.Message;
}
finally
{
command.Connection.Close();
}
return result;
одну строку добавляю так:
var result = string.Empty;
var command = new MySql.Data.MySqlClient.MySqlCommand();
var connectionString = "";
try
{
command.Connection = new MySql.Data.MySqlClient.MySqlConnection(connectionString);
}
catch (Exception e)
{
result = "Musql error connection";
}
if (result!=String.Empty)
{
return result;
}
try
{
command.Connection.Open();
string request = "INSERT INTO `out` (column1, column2) VALUES (@site, @id)";
MySql.Data.MySqlClient.MySqlCommand com = new MySql.Data.MySqlClient.MySqlCommand(request, command.Connection);
com.Parameters.AddWithValue("@site", "url1");
com.Parameters.AddWithValue("@id", "id1");
com.ExecuteNonQuery();
}
catch (MySql.Data.MySqlClient.MySqlException e)
{
result = "Mysql error2"+e.Message;
}
finally
{
command.Connection.Close();
}
return result;