1
I have the following code:
using System;
using System.Linq;
using FirebirdSql.Data.FirebirdClient;
using System.Configuration;
using System.Data;
namespace TblCliente
{
public class Program
{
static void Main(string[] args)
{
FbConnection fbConnectionPrincipal = new FbConnection
{
ConnectionString = ConfigurationManager.ConnectionStrings["strFirebirdPrincipal"].ToString()
};
FbConnection fbConnectionSecundaria = new FbConnection
{
ConnectionString = ConfigurationManager.ConnectionStrings["strFirebirdSecundaria"].ToString()
};
FbDataAdapter fbDataAdapterPrimario = new FbDataAdapter("SELECT * FROM PRODUTO WHERE PRODUTO.CODPROD = '000399'", fbConnectionPrincipal);
FbDataAdapter fbDataAdapterSecundario = new FbDataAdapter("SELECT * FROM PRODUTO WHERE PRODUTO.CODPROD = '000399'", fbConnectionSecundaria);
DataTable dataTableP = new DataTable();
DataTable dataTableS = new DataTable();
fbDataAdapterPrimario.Fill(dataTableP);
fbDataAdapterSecundario.Fill(dataTableS);
dataTableP.Merge(dataTableS);
var Produto = dataTableP.AsEnumerable().Distinct();
Console.ReadKey();
}
}
}
This code brings results from two distinct databases and included in DataSet
different, after that I made a DataSet.Merge
and on top of it were returned the distinct values.
How do I include these distinct lines in a new database ?
Opening a new connection and doing the Insert?
– Leandro Angelo
This new connection would be the fbConnectionSecundaria!
– Charles Andrade
Then just write the insert using the
fbConnectionSecundaria
even...– Leandro Angelo