dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: DataReport is givin error

  1. #1
    Join Date
    Sep 2011
    Posts
    1

    DataReport is givin error

    Below is my codes :

    Private Sub btnRpt1_Click()
    Dim strBC, strDBI, strDBN, strJouFrm, strJouTo, strSQL, strTransDate, recCou As String
    strIndex = cmbDBR.ListIndex + 1
    strDBI = Check_DB(strIndex, "ID")
    strDBN = Check_DB(strIndex, "NM")
    strBC = txtBCR.Text
    strJouFrm = txtJouFrmR.Text
    strJouTo = txtJouToR.Text
    strTransDate = strPayDate2
    If txtBCR.Text = "" Or txtJouFrmR.Text = "" Or txtJouToR.Text = "" Then
    MsgBox "Please Key In All The Field !", vbOKOnly, "Validation"
    Else
    Screen.MousePointer = 11

    On Error Resume Next

    Dim de As New dtenvRpt
    Dim QryDef As New ADODB.Recordset

    strSQL = "SELECT * from table_name "

    Call OpenConnection 'opens a DB connection
    QryDef.Open strSQL, conn
    recCou = QryDef.RecordCount

    Set de = New dtenvRpt
    Set rptSum.DataSource = de

    If recCou = 0 Then
    MsgBox "No Data. Please check your inputs.", vbOKOnly, "REPORTS"
    Exit Sub
    Else
    With rptSum.Sections("pageheader")
    .Controls("lblPayDateVal").Caption = strTransDate
    End With

    rptSum.Show

    Err = 0
    Set de = Nothing
    Unload dtenvRpt
    End If

    CloseConnection 'closes a connection
    End If
    End Sub

    I am tryinto open a data report in VB6 using this code. strTransDate is a date that I am passing from user input. I haven't pass any query result into the report yet. I want to test my report wether it opens but I'm getting error after the report opens. Which is Failed getting Rowset(s) from current data source.

    Please guide. Thank you.

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,337

    Re: DataReport is givin error

    do you have a table in your database named table_name ? If not then this is your problem
    Code:
    strSQL = "SELECT * from table_name "
    table_name must be the actual name of the table you want to select data from.


    use [code][/code] tags when posting code


    This also looks like it could be a problem
    Code:
    Set de = New dtenvRpt
    Set rptSum.DataSource = de
    Last edited by DataMiser; September 13th, 2011 at 07:20 AM.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: DataReport is givin error

    Well spotted, DataMiser.

    I'd draw your attention also to this line:
    Code:
    Dim strBC, strDBI, strDBN, strJouFrm, strJouTo, strSQL, strTransDate, recCou As String
    This is an often seen mistake when declaring variables. Only the last one recCou is becoming a string. All the others become Variants.
    To declare a variable properly the data type has to be defined for each variable explicitly.
    Code:
    Dim strBC as String, strDBN as String....
    If no data type is given, it defaults to Variant.
    I thought I'd point that out, although this might in your case here not be responsible for the error.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)