on 2016 Aug 10 12:52 AM
I have downloaded xi4_rassdk_net_dg_en.chm, which shows what properties to set and methods to call using the RAS SDK, but it doesn't tell you where put the code.
I have also downloaded some sample projects from http://scn.sap.com/docs/DOC-50373, but cannot get the one I really want to see to work, which is how to add a table. I have also downloaded SAP Crystal Reports NET SDK Tutorial Sample Code from http://scn.sap.com/docs/DOC-6948, but the readme gives instructions to set up ODBC in the control panel. I'm running Windows 10, and I cannot find the settings the readme talks about.
Here is the code where the error occurs:
Public Class Form1
Dim boReportDocument As CrystalDecisions.CrystalReports.Engine.ReportDocument
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim boConnectionInfo As CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo
Dim boPropertyBag As CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag
Dim boPropertyBagConnection As CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag
Dim boTable As CrystalDecisions.ReportAppServer.DataDefModel.Table
boReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
boReportDocument.Load("C:\Crystal Reports\RAS SDK\Samples\Add Table\NET-VB2005-WIN_RAS-Unmanaged_CR12_Add_Database-Table\SimpleRCAPIReport.rpt")
Dim boReportClientDocument As CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument = boReportDocument.ReportClientDocument
'This will add a database table using an ODBC connection. Since the report already has the Customer Table, we will add the Orders Table
'Create the DB connection
boConnectionInfo = New CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo
'Set new table logon properties
boPropertyBag = New CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag
'Because this is an ODBC connection to an access database, there is no need to specify the database
boPropertyBag.Add("DSN", "Xtreme Sample Database 2005")
'Set the connection info objects members
boPropertyBagConnection = New CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag
'1. Pass the Logon Properties to the main PropertyBag
'2. Set the Server Description to the new System DSN
'3. Set the Database DLL
boPropertyBagConnection.Add("QE_LogonProperties", boPropertyBag)
boPropertyBagConnection.Add("QE_ServerDescription", "Xtreme Sample Database 2005")
boPropertyBagConnection.Add("Database DLL", "crdb_odbc.dll")
boConnectionInfo.Attributes = boPropertyBagConnection
'Blank username and password since this database does not require them
boConnectionInfo.UserName = ""
boConnectionInfo.Password = ""
'The Kind of connectionInfos is CRQE (Crystal Reports Query Engine).
boConnectionInfo.Kind = CrystalDecisions.ReportAppServer.DataDefModel.CrConnectionInfoKindEnum.crConnectionInfoKindCRQE
'Now create and add the table
boTable = New CrystalDecisions.ReportAppServer.DataDefModel.Table
boTable.Name = "Orders"
boTable.ConnectionInfo = boConnectionInfo
boReportClientDocument.DatabaseController.AddTable(boTable, Nothing) ' Get error here
boCrystalReportViewer.ReportSource = boReportDocument
End Sub
the error is in the attached file.
The sample is for VB 2005, could that be problem?
Thanks
What .NET SDK package are you actually using?
The error is exactly as id indicates, you are failing to connect to your database.
If you don't have a DSN then you need to create one to your DB.
Try creating a new report and selecting your database and drop a table and a few fields onto the report and save it.
Then search for this KBA - 1553921 - Is there a utility that would help in writing database logon code? it generates the code for you to make the connection, then use above code to add your table and then link it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I read that the RAS SDK comes with CR for VS, so I'm using that. I am using CR for VS 13.0.15
I am using CR's Database Expert to connect to the database. The problem with that is you (if you can, I don't know how) can't just add a database, you have to add at least one table.
I downloaded the CodeBuilder-RasConnectionInfo.zip from KBA - 1553921. You can see where I call the function it generated in the attached file. The function got the same error I'm getting.
The sample from http://scn.sap.com/docs/DOC-50373 uses an Access database. I cannot drop a table in Server Explorer.
Thanks,
Ralph
Hi Ralph,
What you are doing is way beyond a "starter", and I don't mean anything by that....
What we always recommend is to use Crystal Reports Designer first so you get to understand how it works. The reason being is the SDK does the same thing, so what ever work flow you use in CRD you do the same in the SDK's.
Crystal Reports can connect to a database, but what is the point if you don't have any tables or fields?????
You need to decide that before connecting and creating a report in RAS.
Be aware that CR Designer will let you get away with bad formula and other incomplete objects, the SDK will NOT, all objects must be valid and available.
All Database, Tables and Fields are saved in the RPT file so when connecting we have a reference to them. If they don't exist the SDK will through an error.
Template reports are a much easier way to start, they can have the basics, have the DB and table selected, you can add fields later, create a bunch of dummy formula fields and text objects and use them using the .Modify() functions and delete the ones not used...
Don
Hi, Don,
No offense taken - I am a beginner.
I have written a desktop application that uses a SQLServer Compact Edition database and CR. What I want to do is be able to programmatically add the new tables and fields to tables, and update the reports to use the new fields. Is there a way to do that without the RAS SDK?
Thanks,
Ralph
User | Count |
---|---|
77 | |
10 | |
10 | |
10 | |
10 | |
9 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.