Solved

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

Posted on 2006-06-22
4
3,151 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
  • 2
4 Comments
 
LVL 100

Accepted Solution

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

mlmcc
0
 
LVL 42

Assisted Solution

by:frodoman
frodoman earned 250 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 100

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

840 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