zzzprojects / Bulk-Operations

C# SQL Bulk Operations | High-performance C# bulk insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL, and SQLite.
https://bulk-operations.net
142 stars 36 forks source link

Error : Atleast one members must be declared. #51

Closed JPgituser closed 5 years ago

JPgituser commented 5 years ago

Good afternoon,

I can not seem to get this working. What i am trying to do is :

A BulkInsert from an ODBC Datasource, into an MySQL table as target, through an OdbcDataReader.

When using an DataTable to a MySQL table ,it works just fine. When using an OdbcDataReader, but the target is a MS SQL database , it works just fine

But the combination OdbcDataReader to a MySql database as target gives the error message : "Atleast one members must be declared."

The code I use is something like this : (the simplified version)

            //Open the ODBC connection and fill the Odbcreader  (This is the Datasource)
            OdbcConnection sourceConn = new OdbcConnection(SourceOdbcConnString); 
            sourceConn.Open();
            OdbcDataReader Odbcreader;
            OdbcCommand commandTC = new OdbcCommand
                    {
                        Connection = sourceConn
                        CommandText = "SELECT * FROM TestTable" 
                    };
            Odbcreader = commandTC.ExecuteReader();     

            //Open the MySQL connecton and try to BulkInsert the contents of the Odbcreader

            MySqlConnection mySqlTargetConn = new MySqlConnection("server=localhost;userid=*******;pwd=**********;database=test");

            using (BulkOperation bulk = new BulkOperation(mySqlTargetConn))
                {
                    bulk.DestinationTableName = "TestTableTarget";
                    bulk.BulkInsert(Odbcreader);
                }
            Odbcreader.Close();
            mySqlTargetConn.Close()

Can you perhaps point me in the right direction ? I would be very happy if i got this working.

Best Regards,

J. Fielder

JonathanMagnan commented 5 years ago

Hello @JPgituser ,

That's definitively an error throw by our library when a getter or setter cannot be created.

I'm surprised that it works with MS SQL and not MySQL. I would have expected the same behavior (whether it works or not)

We will try to reproduce this error and fix it. Perhaps that's only a small issue that we are not compatible yet with OdbcDataReader.

Best Regards,

Jonathan

JPgituser commented 5 years ago

Hello Jonathan,

I tested again just to be sure, and can confirm that using MS SQL as target database is indeed working.

Best Regards, J.Fielder

JPgituser commented 5 years ago

Oops i didnt mention I am using Mariadb not Mysql, (that could make a difference)

JonathanMagnan commented 5 years ago

Hello @JPgituser ,

A new version has been released.

Could you try it and let me know if your issue is fixed?

Best Regards,

Jonathan

JPgituser commented 5 years ago

Good afternoon Jonathan,

It works like a charm ! (On Mariadb as well as Mysql)

Thanks for your quick solution, and have a nice day !

Best Regards,

J. Fielder