Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 2nd, 2008, 03:21 AM
Registered User
 
Join Date: Apr 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Exporting to excel

Good day to all, I am also new in VB Programming. I am making a program that shows the data from SQL 2000 server database to a datagrid in VB and after that, export it to MS Excel.

The program runs like this, the user will select the range of date of the transactions they want to see, when they select a short range like from Jan. 1 to Jan 2, and it will produced only 200 to 1000 rows in the datagrid, there was no error. But when they are producing a large no. of data, the program got the "Run-time error '-2147467259 (80004005)': Data provider or other service returned an E_FAIL status." when the program hit the highlighted code below.

Sub GetData()
    If cboDeptDesc.Text = "Select" Then
        strSQL = " SELECT * FROM MOTIVATION_MIKE M "
        strSQL = strSQL & " WHERE M.TRAN_DATE >= '" & Format(txtDateFrom, "yyyy/mm/dd") & " '"
        strSQL = strSQL & " AND M.TRAN_DATE <= '" & Format(txtDateTo, "yyyy/mm/dd") & " '"
    Else
        strSQL = " SELECT * FROM MOTIVATION_MIKE M "
        strSQL = strSQL & " WHERE M.DEPT_DESC = '" & cboDeptDesc.Text & "' "
        strSQL = strSQL & " AND M.TRAN_DATE >= '" & Format(txtDateFrom, "yyyy/mm/dd") & " '"
        strSQL = strSQL & " AND M.TRAN_DATE <= '" & Format(txtDateTo, "yyyy/mm/dd") & " '"
    End If
        Set rsData = New ADODB.Recordset
        rsData.CursorLocation = adUseClient
        rsData.Open strSQL, RRString, adOpenKeyset, adLockOptimistic
        Set DataGrid1.DataSource = rsData
        lblrecords.Caption = rsData.RecordCount
        lblrecords.Refresh
        totalRec = Val(lblrecords.Caption)
End Sub

I hope to get a quick response to this problem, thanks so much in advance.

Best Regards,
Mike

 
Old May 2nd, 2008, 02:24 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Put a Breakpoint before this, and with the next statment the caption setting, hover over rsData.RecordCount and see if it shows a value in the tooltip that pops up.

If that behavior doen't take place, Highlight rsData.RecordCount, then right-click the highlight, and add it to the watch window.

Then look in the watch window to see if there is any value in the object, or if it is an error instead.
 
Old May 3rd, 2008, 05:26 AM
Registered User
 
Join Date: Apr 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you so much for your response Mr. Brian, I really appreciate it but, can you show me how to do it?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting From Access To Excel jimnich Access VBA 17 February 8th, 2008 07:23 AM
exporting to excel caveatashish Classic ASP Basics 0 November 3rd, 2006 05:08 AM
Exporting to Excel swhite Access VBA 2 September 18th, 2003 09:42 AM
Exporting to Excel JJ Access 1 June 9th, 2003 11:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.