Data Connectivity
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Data Connectivity
Message Icon Topic: Connect to AS400 using OLE DB Post Reply Post New Topic
Author Message
ohioguy_tim
Newbie
Newbie
Avatar

Joined: 11 Dec 2008
Location: United States
Online Status: Offline
Posts: 9
Quote ohioguy_tim Replybullet Topic: Connect to AS400 using OLE DB
    Posted: 13 Oct 2009 at 8:14am
Hello
 
I'm using ASP.NET 3.5 and VB.NET to run a report written in Crystal Reports XI. I'm using the code sample from Brian book, CR .NET 2005/2008. I have used the code sample to run reports that access SQL Server without any problems. Now I need to access an AS400 using OLE DB. I copied the code and changed the logon information to match my AS400 but I keep getting error message that I can't login. If anyone has any ideas as to why its not working, I would appreciate it. Here is my code:
 

Dim myReportDocument As New ReportDocument

Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

Dim ReportName = "myreportList2.rpt"

Dim reportPath As String = Server.MapPath(ReportName)

Dim reportServer As String = Server.MachineName

myReportDocument.Load(reportPath)

CrystalReportViewer1.ReportSource = myReportDocument

CRServer = "xxx.xxx.x.x"

CRDatabase = ""

CRUser = "myuser"

CRPassword = "mypassword"

Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()

myConnectionInfo.ServerName = CRServer

myConnectionInfo.DatabaseName = CRDatabase

myConnectionInfo.UserID = CRUser

myConnectionInfo.Password = CRPassword

SetDBLogonForReport(myConnectionInfo, myReportDocument)

Session("myReportDocument") = myReportDocument

CrystalReportViewer1.Visible = "True"

End Sub

Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo, ByVal myReportDocument As ReportDocument)

Dim tables As Tables = myReportDocument.Database.Tables

For Each table As CrystalDecisions.CrystalReports.Engine.Table In tables

Dim tableLogOnInfo As TableLogOnInfo = table.LogOnInfo

tableLogOnInfo.ConnectionInfo = myConnectionInfo

table.ApplyLogOnInfo(tableLogOnInfo)

Next

End Sub

 

Thank you.

Ohioguy_tim
IP IP Logged
ohioguy_tim
Newbie
Newbie
Avatar

Joined: 11 Dec 2008
Location: United States
Online Status: Offline
Posts: 9
Quote ohioguy_tim Replybullet Posted: 28 Oct 2009 at 5:56am
Hello
 
I was able to resolve my problem.
 
I like creating my reports in Crystal Reports XI then using VB.NET/VS2008 to create an application where users can pick which report they want to run. This works fine for MS SQL reports but not for reports that access the AS400. I can create and run reports in CR XI for AS400. Just can't serve them up in VB.NET/VS2008.
 
To fix my problem. I recreated my report that accesses the AS400 in Visual Studio 2008. Then I was able to serve it up to users without any problems. From what I understand is the assemblies for CR XI are 11.0. Visual Studio 2008 assemblies are 10.5.3700. My only two options are recreate my AS400 report in Visual Studio 2008 or move up to CR 2008 because its compatible with VS2008.
 
Hope my posting of the answer to my own problem saves others from many hours of research and hair pulling.
 
Ohioguy_tim
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.078 seconds.