0
For what you said, just create the tables in Bd and perform CRUD(Create,Read,Update,Delete) by the application.
Example: As you did not specify which bank you are using I will use Postgres, but should suit anyone.
First install a ADO.NET data provider in the project, can be done by Nuget Manager. I installed Npgsql.
Create the database to receive this data.
CREATE TABLE public."exemplodb"
(
browse character varying NOT NULL,
colunadadb1 character varying,
colunadadb2 character varying,
colunadadb3 character varying,
colunadadb4 character varying,
CONSTRAINT "PK" PRIMARY KEY (browse)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public."exemplodb"
OWNER TO postgres;
Now by clicking the Send BD button you program your data handling.
private void enviardbButton_Click(object sender, EventArgs e)
{
using (NpgsqlConnection conn = new NpgsqlConnection("sua connection string aqui"))
{
try
{
string commandText =
$"insert into exemplosdb " +
$"(browse, colunadadb1, colunadadb2, colunadadb3, colunadadb4) " +
$"values ('{browseComboBox.Text}' '{colunadb1ComboBox.Text}', " +
$"'{colunadb1ComboBox.Text}', '{colunadb1ComboBox.Text}', '{colunadb1ComboBox.Text}');";
int linhasAfetadas = 0;
using (NpgsqlCommand command = new NpgsqlCommand(commandText, conn))
{
conn.Open();
linhasAfetadas = command.ExecuteNonQuery();
conn.Close();
}
if (linhasAfetadas == 1)
{
//Dados da tela gravados com sucesso.
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
}
}
Making it clear that this is a super simplified example just to demonstrate! Several important concepts, such as separation of responsibilities, layered programming, among others were ignored for simplicity, but are very important.
You want to read Excel from your application, or you want to export data from an excel document to a new table in the database?
– Rafael Marcos
@Rafaelmarcos I want to read and then export to a new database
– Pedro Azevedo
You will have several different documents or just one ?
– Rafael Marcos
For now I only have 2
– Pedro Azevedo