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 November 18th, 2007, 04:35 AM
Registered User
 
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datareport need help please

Hi, i'm trying to use DataReport with VB 6. But got Run-time error '13': Type mismatch. Here is my code:

Code:
Private Sub cmdGenerateReport_Click()
    Dim conString As String
    conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\" & "Database.mdb;"

    Set con = New ADODB.Connection
    con.Open conString

    Set rec = New ADODB.Recordset

    query = "select name from ms_people"

    rec.Open query, con, adOpenStatic, adLockOptimistic

    If rec.RecordCount > 0 Then
        Set DataReport1.DataSource = rec
        DataReport1.Sections("Section1").Controls("Text1").DataField = "name"
        DataReport1.Show
    End If

    rec.Close
End Sub
The code error at 'Set DataReport1.DataSource = rec'.
DataReport1 is a simple data report (i didn't change the attributes)
Any help would be very grateful >.<. Thanks

 
Old November 19th, 2007, 08:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there.. are you sure that datasource receive a recordset?? not a conection string??

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old November 19th, 2007, 08:33 PM
Registered User
 
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, thanks for your reply :D
I read people's code that datasource receives recordset.
If it's connection string, could you please tell me how the code should be. thanks

 
Old November 20th, 2007, 08:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

that's why I ask you if you were sure.. maybe it can receive recordsets, But I never work with it. I pointed it out because the kind of error you are receiving is like datasource expect a different type of object (that I don't know which type, did you check the help for it??)

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
datareport error binil Beginning VB 6 0 December 15th, 2005 01:57 AM
VB6 DataReport and ADO mike123abc Pro VB 6 1 June 8th, 2004 12:01 AM
DataReport btpoole VB Databases Basics 1 February 19th, 2004 10:46 AM
Datareport Group By btpoole VB Databases Basics 0 October 26th, 2003 04:51 PM
DataReport With DataShaping acko Pro VB 6 0 August 20th, 2003 12:43 PM





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