使用sqlce和ErikEJ.SqlCe库

时间:2012-01-11 16:27:13

标签: dll sql-server-ce sql-server-ce-4

我收到了这个错误

Error 1 The type 'System.Data.SqlServerCe.SqlCeTransaction' is defined in an assembly is not referenced That. You Must add a reference to assembly 'System.Data.SqlServerCe, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 89845dcd8080cc91'.

我在哪里下载版本4.0.0.0?我没找到。

Error   2   The type 'System.Data.SqlServerCe.SqlCeConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'.

同样的问题..

Error 3 The best overloaded method match for 'ErikEJ.SqlCe.SqlCeBulkCopy.WriteToServer (System.Data.DataTable)' Some invalid arguments have

过载?只有我想用它:s

Error   88  The best overloaded method match for 'ErikEJ.SqlCe.SqlCeBulkCopy.WriteToServer(System.Data.DataTable)' has some invalid arguments   

??它允许数据表。我不明白..

Error   94  Argument '1': cannot convert from 'System.Data.DataTable [c:\Program Files\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\System.Data.dll]' to 'System.Data.DataTable []'

转换为datatable [] ??什么?

这是我的方法代码。

private void DoBulkCopy(bool keepNulls,System.Data.DataTable tabla,string nombretabla)     {         if(tabla.Rows.Count> 0)         {

        ErikEJ.SqlCe.SqlCeBulkCopyOptions options = new ErikEJ.SqlCe.SqlCeBulkCopyOptions();
        if (keepNulls)
        {
            options = options |= ErikEJ.SqlCe.SqlCeBulkCopyOptions.KeepNulls;
        }
        //using (SqlCeBulkCopy bc = new SqlCeBulkCopy(connectionString, options))

        using (SqlCeBulkCopy bc = new SqlCeBulkCopy(Resco.Data.Database.Instance.ConnectionString,options))
        {

            bc.DestinationTableName = nombretabla;

            try
            {
                bc.WriteToServer(tabla);
            }
            catch(Exception ex) { }
        }
        }

}

1 个答案:

答案 0 :(得分:0)

简单方法 - >使用程序包管理器控制台安装到项目。

PM> Install-Package ErikEJ.SqlCeBulkCopy

请参阅http://nuget.org/packages/ErikEJ.SqlCeBulkCopy