BUG: SQL-DMO: ExportData Method of BulkCopy Object Causes VB Run-Time Error

ID: Q238558


The information in this article applies to:

BUG #: 18818 (SQLBUG_65)

SYMPTOMS

When you invoke the SQL Server Distributed Management Object's (SQL-DMO) ExportData method from within a Visual Basic application, you receive a run-time error -2147211455 (SQL-DMO error 10049) when the source table contains more than 999 rows.

Additionally, the return value from the ExportData method always returns the value 0 instead of the number of rows exported, as stated in the SQL-DMO documentation.


WORKAROUND

To work around this problem, add On Error processing to your project and declare the BulkCopy object using the WithEvents keyword. Doing so also enables you to determine the number of rows exported by evaluating the return value of the ExportData method.


STATUS

Microsoft has confirmed this to be a problem in SQL Server version 6.5.


MORE INFORMATION

SQL-DMO error 10049 is an informational message from DB-Library informing the caller every 1000 rows that 1000 rows have been successfully exported. However, the run-time error triggered in the Visual Basic application depends on if and how an error-handler has been implemented. To get the SQL-DMO error-number you need to subtract the constant vbObjectError from the value of Err.Number as in the following example from SQL Server Books Online:


On Error Resume Next
oSQLServer.Connect "myserver", "mylogin", "mypassword"
If Err.Number <> 0 Then
   Debug.Print Err.Source & " Error " & _
      Err.Number - vbObjectError & ": " & _
      Err.Description
End If 
Using WithEvents, you get two new Visual Basic event procedures added automatically to your Visual Basic project: BatchImported and RowsCopied. You may use the RowsCopied event procedure to monitor the progress of the export.

Additional query words: DMO SQLOLE SQLDMO ExportData ImportData BulkCopy object WithEvents 80042741


Keywords          : kbprg SSrvDMO SSrvProg SSrvVisB kbbug6.50 kbSQLServ650bug 
Version           : winnt:6.5
Platform          : winnt 
Issue type        : kbbug 

Last Reviewed: August 9, 1999