[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Crystal Report ASP Stream to PDF "Failed to retrieve data from the database"

Posted on 2006-06-22
4
Medium Priority
?
3,167 Views
Last Modified: 2012-06-27
I have a Crystal Report (version XI) that I launch from a VB.NET Web App.  It has worked for months.  Then, yesterday, it suddently stopped working.  I redeployed my files to the web server, thinking maybe something got corrupted out there, but it didn't help.  The code I am using to run the Crystal Report (that worked fine for a long time) is as follows:

    Private Sub ShowReportEmbedded()
        Dim oRpt As sl_List4
        oRpt = New sl_List4
        oRpt.SetDatabaseLogon(strUser, strPassword)

        sSQL.Length = 0
        sSQL.Append("    {SL_LIST.ListSite} = '" & Request.Item("slSite").ToString & "' ")
        sSQL.Append("AND {SL_LIST.ListRev} = '" & Request.Item("slRev").ToString & "' ")
        sSQL.Append("AND date({SL_LIST.ShipListDate}) = date('" & CDate(Left(Request.Item("slDate").ToString, 2) & "-" & Mid(Request.Item("slDate").ToString, 3, 3) & "-" & Right(Request.Item("slDate").ToString, 2)) & "') ")

        oRpt.RecordSelectionFormula = sSQL.ToString

        Dim st As System.IO.MemoryStream
        st = oRpt.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat)

        Response.ClearContent()
        Response.ClearHeaders()
        Response.ContentType = "application/PDF"
        Response.AddHeader("Content-Disposition", "inline; filename=list.pdf")
        Response.BinaryWrite(st.ToArray)
        Response.Flush()
        Response.Close()
    End Sub

The error says:  Failed to retrieve data from the database.

Any ideas?
0
Comment
Question by:AptDev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 1000 total points
ID: 16965085
What has changed on the machine?

mlmcc
0
 
LVL 42

Assisted Solution

by:frodoman
frodoman earned 1000 total points
ID: 16969199
What type of database are you connecting to?  Have you verified that you can still connect from this machine to the database?

It could be many, many things, but my first suspicion would be that either a patch has been applied which has changed the security settings or a firewall has been changed.  In either case, the report cannot reach the database any longer.  Try executing the same report standalone (if you can) in the same location and see if it works that way.

frodoman
0
 

Author Comment

by:AptDev
ID: 16993885
After reading your question "What changed" it suddenlty hit me that I had added a field to that table.  A little more exploration showed me the line that was causing the problem was the line about dates.   I just worked with it until it worked.  Although I have no idea how the table changed to require the new code, I simply changed from a date to a datetime and it worked flawlessly.  Thank you both for your comments that lead me in that direction.  Here is the only change I made to the above code to get it to work:

sSQL.Append("AND {SL_LIST.ShipListDate} = datetime('" & CDate(Left(Request.Item("slDate").ToString, 2) & "-" & Mid(Request.Item("slDate").ToString, 3, 3) & "-" & Right(Request.Item("slDate").ToString, 2)) & "') ")

Thank you both for your endless help on this forum!
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 16998278
Anytime you change the table you need to VERIFY THE DATABASE in Crystal.  Under the DATABASE menu

Glad i could help

mlmcc
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question