SQLBulkCopy is not inserting on table

sqlbulkcopy vb.net

Question

The SQLBulkCopy is what I'm utilizing to import data into my table. It functions well, however sometimes my table's data just doesn't load, and I don't get any error messages.

Here's my code:

Dim dtbTabelaLoad As New DataTable("base_fat_contrato_linha_composicao")
dtbTabelaLoad.Columns.Add("fk_id_contrato")
dtbTabelaLoad.Columns.Add("access_nbr")
dtbTabelaLoad.Columns.Add("fk_id_composicao")

For Each linha As Linha In objLinhaFinal
    Dim strContrato As String = linha.ComposicaoLinha.NumeroContrato
    Dim strComposicao As String = linha.ComposicaoLinha.NumeroComposicao
    Dim strNumeroLinha As String = linha.NumeroLinha

    dtbTabelaLoad.Rows.Add(strContrato, strNumeroLinha, strComposicao)
Next

Dim load As SqlBulkCopy = New SqlBulkCopy(strStringConexao, SqlBulkCopyOptions.Default)
load.DestinationTableName = "base_fat_contrato_linha_composicao"
load.ColumnMappings.Add("fk_id_contrato", "fk_id_contrato")
load.ColumnMappings.Add("access_nbr", "access_nbr")
load.ColumnMappings.Add("fk_id_composicao", "fk_id_composicao")

load.WriteToServer(dtbTabelaLoad)
load.Close()

I run this code through my application several times, but sometimes the data just does not show up on the table.

1
0
2/7/2018 5:44:47 PM

Accepted Answer

I found another process that was removing the inputted data after seeing the Jacob remark. So my code is working well (happily).

Tks.

0
2/16/2018 2:01:23 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow