Reputation: 1
I am trying to drop WebEx meeting data to my company's SQL server. After running line by line, the csv data and datatable are loaded. However when I run the bulk copy method, it returns this error.
The given value of type String from the data source cannot be converted to type int of the specified target column.
Each DestinationColumn,DestinationOrdinal,SourceColumn,andSourceOrdinal all return as -1.
What am I missing? here is the attempt to perform the bulk copy:
try {
$bulkCopy.WriteToServer($dt)
Write-Host "Data successfully inserted into the table."
}
catch {
Write-Host "An error occurred: $_"
foreach ($errorRecord in $_.Exception.Errors) {
Write-Host "SQL Error: $($errorRecord.Message)"
}
} finally {
$bulkCopy.Close()
}
I have checked that all the column names align and have changed most of the data types in sql to variables as int's can be tricky. Currently only the meetingId is an int and start/end column name is datetime. Everything else is either a varchar or nvarchar. I am looking for the data to show in the the SQL server but so far, only the column names are there. Each column in the script have $dt.Columns.Add and rows are in my foreach loop with $dataRow.
Upvotes: 0
Views: 75