Solved

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

Posted on 2006-06-22
4
3,124 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now