Database logon to a Crystal at runtime in VB.NET & Stored Procedure

Answered Database logon to a Crystal at runtime in VB.NET & Stored Procedure

  • 26 April 2012 14:41
     
      Memiliki Kode

    Trying to created a vb.net program to run some existing crystal reports.  Doing a test program this code correctly ran the report;

    Dim cryRpt As New ReportDocument
    cryRpt.Load("C:\MyCrystalReport1.rpt")
    CrystalReportViewer1.ReportSource = cryRpt
    CrystalReportViewer1.Refresh()

    The issue being that it requires the user to enter in the database logon information.  As you can guess this is a big no no...

    So found this extremely helpful FAQ (please do not link to this as the answer)

    http://www.tek-tips.com/faqs.cfm?fid=4870

    The problem is the Crystal Reports uses a stored procedure. so when report is run it returns an error on this line;

    crTable.Location = crConnectionInfo.DatabaseName & ".dbo." & crTable.Location.Substring(crTable.Location.LastIndexOf( 
    ".") + 1) 

    With the error;

    The table 'MyStoredProcedure;1' could not be found. Error in File My Report {DB40FA45-0294-4C59-AD34-703FED5BBF76}.rpt: The table could not be found.

    Before you ask "Is the stored procedure there?", it is.  The report can be run inside Crystal Reports to the give database and stated above if the logon is not passed the report works correctly.  If it helps this is what that line of code is exciting;

    "MyDatabase.dbo.Proc(MyStoredProcedure;1)"

    • Dipindahkan oleh Bob_BaoMVP 27 April 2012 6:43 (From:Visual Basic General)
    •  

Semua Balasan

  • 26 April 2012 19:11
     
     Jawab
    probably the substring is the part erroring you out is a best guess. But you can pass username and password information to a crystal reports file viewer in asp.net I know but I haven't done it in vb.net program but would guess its very similar and not that difficult. I work at a school system as an IT and the report is for the high school branch so it has to work its best everytime report cards go out because their are 2000 high school students and at max it takes a minute or two to search through them. I did this so i could see the asp.net page that the school has.

    Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://jefferycarlsonblog.blogspot.com/


  • 27 April 2012 3:24
     
     Jawab

    Hi Xaphann,

    Welcome to the MSDN forum.

    The Crystal report is third party software. I’m afraid that your topic about Crystal report is also unsuitable here. I will move this thread to offtopic forum. Please connect to the official website of Crystal report to ask for help: http://www.sdn.sap.com/irj/scn/advancedsearch?query=crystal+report

    Sorry for any inconvenience and have a nice day.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us