dcsimg
Results 1 to 10 of 10

Thread: [RESOLVED] how to create the data report from text file?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Posts
    108

    Resolved [RESOLVED] how to create the data report from text file?

    Hi,
    I already know how to import text file to datagrid,may i how to create the data report from the text file??

    my text file content:
    2310047019902,50,18/12/2013,08:24
    2310057019909,80,18/12/2013,08:24
    2310073019907,2000,18/12/2013,08:24
    2310048019901,50000,18/12/2013,08:25
    2310067019906,2,18/12/2013,08:25


    my code:
    Module
    Code:
    Option Explicit
    
    Public cn As New ADODB.Connection
    Public rs As New ADODB.Recordset
    
    Public Sub Connect()
    
    Dim Path1 As String
    
    Path1 = App.Path & "C:\aaa\test.txt"
    cn.CursorLocation = adUseClient
    
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\aaa\;Extended Properties=""text;HDR=No;FMT=Delimited"""
    
    With rs
            .ActiveConnection = cn
            .CursorLocation = adUseClient
            .CursorType = adOpenStatic
            .LockType = adLockReadOnly
            .Source = "Select * From test.txt"
            .Open
    
    End With
    
    End Sub
    
    Public Sub RSCheck()
    If rs.State = 1 Then rs.Close
    End Sub
    command button
    Code:
    Private Sub Command1_Click()
    
    Dim SQL As String
    
    If rs Is Nothing Then
        Set rs = New ADODB.Recordset
    End If
    
    RSCheck
    
    SQL = "Select * From test.txt"
    rs.Open SQL, cn, adOpenStatic, adLockReadOnly
    
    Set DataReport1.DataSource = rs
       
    DataReport1.Show
        
    End Sub
    
    Private Sub Form_Load()
    
    Connect
    
    If Not rs.BOF And Not rs.EOF Then
    rs.Sort = "F1 ASC"
    rs.Requery
    Set DataGrid1.DataSource = rs
    End If
    
    End Sub
    your help is much appreciated

  2. #2
    Frenzied Member gibra's Avatar
    Join Date
    Oct 2009
    Location
    ITALY
    Posts
    1,667

    Re: how to create the data report from text file?

    You should use the DataReport Designer to make your report.

    However DataReport isn't a good tool, very obsolete and limited.
    I suggest to use Cristal Report 4.6 (it come with VS6/VB6) that's very very good.
    You will find CR4.6 on your CDs (depend of your version)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Posts
    108

    Re: how to create the data report from text file?

    thank you for your suggestion, but to create the report from database (MS access) is no problem, if from text file i don't know how? can you show me the simple example how to create report (data source: text file) not a .mdb

  4. #4
    Frenzied Member gibra's Avatar
    Join Date
    Oct 2009
    Location
    ITALY
    Posts
    1,667

    Re: how to create the data report from text file?

    Then I cant' help you.

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,646

    Re: how to create the data report from text file?

    I'm not sure what the big deal is here.

    You can do this using a DataEnvironment as a DataSource or you can do it using just an ADO Recordset. In either case you will want to use the Jet 4.0 OLEDB Provider, and you'll want a Schema.ini file to provide information about the structure of your text data file.

    Here's a quick and dirty demo:

    Name:  Sshot DataReport.png
Views: 1934
Size:  23.0 KB

    The truth is that VB6 DataReports were meant to replace Crystal Reports, which was included only to aid in porting old VB5 programs to VB6. Of course the DataReport was meant to become more powerful in future versions of VB, but then The Great Destruction (.Net) came along and nipped progress in the bud.
    Attached Files Attached Files

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Posts
    108

    Re: how to create the data report from text file?

    thank you so much for your demo dilettante, it really help me a lot, but i not familiar using the schema.ini file. if i want to use dataenvironment as a data source like you mention, how to do this? any idea?
    *sorry my english not so well*

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,646

    Re: how to create the data report from text file?

    You would need to use a schema.ini even with a DataEnvironment. There are alternatives but they are more complex.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Posts
    108

    Re: how to create the data report from text file?

    ok, i will try it, my i know how you create your Resource File in vb6 or how to open your project1.res content?

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Posts
    108

    Re: [RESOLVED] how to create the data report from text file?

    Thank again for your help dilettante, I will learn by myself.

  10. #10
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,646

    Re: [RESOLVED] how to create the data report from text file?

    The only thing in the resources was an application manifest. That is completely optional, but VB6 programmers are supposed to know about these things these days.

    You can remove that resource entirely. It has nothing to do with making a DataReport work.


    And here is a partial description of schema.ini file format.
    Last edited by dilettante; Dec 30th, 2013 at 10:28 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width