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



The information in this article applies to:

  • Microsoft SQL Server 6.5

This article was previously published under Q238558
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.


NOTE: This workaround requires the sqlole65.dll file, version 1997.04.02 that is dated 6/16/97.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

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.


Modification Type:MajorLast Reviewed:10/9/2003
Keywords:kbBug kbnofix kbpending kbProgramming KB238558