Windows 7 64bit
SQLite version 3.17.0
sqlite-netFx46-static-binary-x64-2015-1.0.104.0

Note: The code is working correctly with Devart ODBC driver for SQLite 2.1.4
The problem is with System.Data.SQLite

How to reproduce:
ON SQLite
Create database N:\SqLite\outStream.db

CREATE TABLE FromNum (id int NOT NULL, Num numeric(5, 5));
INSERT INTO FromNum (id, Num) VALUES (1, .00000);

On SQL Server

CREATE TABLE [dbo].[ToNum](
                [id] [int] NOT NULL,
                [Num] [numeric](5, 5) NULL,
PRIMARY KEY CLUSTERED
([id] ASC) );

PowerShell script:

[string]ToTableName = "SERVER.Test.dbo.ToNum"
[string]FromFileName = 'N:\SqLite\outStream.db'

[string[]]ttname = ToTableName.Split(".")
[string]ServerName = ttname[0]
[string]dbName = ttname[1]
[string]schema = ttname[2]
[string]DestinationTable = ttname[3]

sqlString = "SELECT * FROM FromNum"
con = New-Object -TypeName System.Data.SQLite.SQLiteConnection -ArgumentList 
"Data Source=$FromFileName"
#$con = New-Object -TypeName System.Data.Odbc.OdbcConnection -ArgumentList 
"DSN=SqLite;Database=N:\SqLite\outStream.db;Direct=True" this is Devart ODBC

con.Open()

SourceSQLCommand = con.CreateCommand()
SourceSQLCommand.CommandText = sqlString

DestinationConnectionString = "Data Source=$ServerName;Initial 
Catalog=$dbName;integrated security=false"

        try
        {
            reader = SourceSQLCommand.ExecuteReader()
            bulkCopy = New-Object ("System.Data.SqlClient.SqlBulkCopy") 
DestinationConnectionString, 
([System.Data.SqlClient.SqlBulkCopyOptions]::TableLock -bor 
[System.Data.SqlClient.SqlBulkCopyOptions]::UseInternalTransaction)
            bulkCopy.DestinationTableName = DestinationTable
                                                bulkcopy.EnableStreaming = true;
            bulkCopy.BatchSize = 50000 #The number of rows in each batch sent 
to the server
            bulkCopy.BulkCopyTimeout = 0 #the number of seconds before a 
time-out
                                                bulkCopy.WriteToServer($reader) 
#copy all rows to the server
        }
        catch
        {
            ex = _.Exception
            Write-Error ex.Message
        }
                                finally
                                {
        reader.Close()
                                con.Close()
                                }

Error Message:

Exception calling "WriteToServer" with "1" argument(s): "The given value of 
type SqlDecimal from the data source cannot be
converted to type decimal of the specified target column."

Dmitriy Burtsev


This message, and any of its attachments, is for the intended recipient(s) 
only, and it may contain information that is privileged, confidential, and/or 
proprietary and subject to important terms and conditions available at 
http://www.stifel.com/disclosures/emaildisclaimers/. If you are not the 
intended recipient, please delete this message and immediately notify the 
sender. No confidentiality, privilege, or property rights are waived or lost by 
any errors in transmission.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to