mtejjini
8 months agoNew Contributor III
Type 'SqlBulkCopy' is not defined.
Hello everyone,
I am trying to create a table in OS with the fx rates by calling an API
while calling the API, i can get the data needed but i have this error <Type 'SqlBulkCopy' is not defined.> that's doesn't allow me to copy the data in a table in OS.
this is a part of the code, the lines in orange are the ones not working.
'create table '
#Region "Create Table Currencies_Mantu"
Dim sSQL As String = $"
IF OBJECT_ID('Table_rate_mantu') IS NOT NULL
BEGIN
DROP TABLE Table_rate_mantu
END
CREATE TABLE Table_rate_mantu (
fromCurrency varchar(255),
exchangeRate numeric(18, 5),
date varchar(255)
);
"
Dim strPeriod As String = ""
Dim strCurrency As String = ""
Dim strPivot As String = ""
Dim strclo As Double = 0
Dim vavg As Double = 0
For Each row As DataRow In dt.Rows
strCurrency = row("fromCurrency")
' strclo = row("Value1")
vavg = row("exchangeRate")
strPeriod = row("Date")
Dim fxRatePkUsingNamesAvg As New FxRatePkUsingNames("exchangeRate", strPeriod, strCurrency, "EUR")
Dim objFxRateUsingNamesAvg As New FxRateUsingNames(fxRatePkUsingNamesAvg, vavg)
Dim objXFResultAvg As XFResult = BRApi.Finance.Data.SetFxRate(si, objFxRateUsingNamesAvg)
' Dim fxRatePkUsingNamesAmount As New FxRatePkUsingNames("ClosingRate", strPeriod, strCurrency, "EUR")
' Dim objFxRateUsingNamesAmount As New FxRateUsingNames(fxRatePkUsingNamesAmount, strclo)
'Dim objXFResult As XFResult = BRApi.Finance.Data.SetFxRate(si, objFxRateUsingNamesAmount)
' BRAPI.ErrorLog.LogMessage(si, "PBO objXFResult=" & objXFResult.Message)
' BRAPI.ErrorLog.LogMessage(si, "ClosingRate= " & strclo)
BRAPI.ErrorLog.LogMessage(si, "exchangeRate=" & vavg)
BRAPI.ErrorLog.LogMessage(si, "Currency=" & strCurrency)
Next
Using dbconn As DbConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si)
BRApi.Database.ExecuteActionQuery(dbconn, sSQL, False, True)
Using bulkCopy As New SqlBulkCopy(dbconn.ConnectionString)
bulkCopy.DestinationTableName = "Table_rate_mantu"
bulkCopy.WriteToServer(dt)
End Using
End Using
#End Region
Do you have any idea why this is not working in OS ?
Thanks
Do you have any idea why this is not working in OS ?
Thanks
.net version changes with V8.
Use Microsoft.Data.SqlClient instead of System.Data.SqlClient;