cancel
Showing results for 
Search instead for 
Did you mean: 

Logon Error when SetTableLocation with RAS SDK

jrgen_bauer2
Explorer
0 Kudos

Hi

I have a lot of Reports based on TTX files. As these don't work anymore in an 64 bit environment with CRVS2010 I tried to make an update program based on an replace_click sample in this newsgroup.

My program is 32 Bit (x86) on an Windows 7 with VS2010. Cr2010 SP1 (13.0.1.220) 32 and 64 Bit is installed.

After creating an XML-file I want to set the new table location with SetTableLocation method:

I always get this Error: Logon Failed. Error in File xxx.rpt: Unable to connect: incorrect log on parameters.

I tested this with two super easy reports created with Crystal Reports 10:

First: 1 Table (based on ttx) with only one String filed. no subreports.

Second: Same report based on an XML File

With Crystal Reports 10 I can update the Report with the created XML-File.


public convert(NewFilename as String)
        Dim lCR As New CrystalDecisions.CrystalReports.Engine.ReportDocument
        lCR = New CrystalDecisions.CrystalReports.Engine.ReportDocument

        Try
            lCR.Load(NewFileName)
            Dim rcd As ISCDReportClientDocument
            rcd = lCR.ReportClientDocument

            For i As Integer = 0 To rcd.SubreportController.GetSubreportNames.Count - 1
                ConvertReportTables(NewFileName, rcd, rcd.SubreportController.GetSubreportNames.Item(i), True)
            Next
            ConvertReportTables(NewFileName, rcd, "", False)
end sub 

Jürgen

Edited by: Jürgen Bauer on Jun 7, 2011 1:55 PM

Accepted Solutions (1)

Accepted Solutions (1)

jrgen_bauer2
Explorer
0 Kudos

Private Sub ConvertReportTables(ByRef destination As String, ByRef lcr As ISCDReportClientDocument, srp As String, issubrpt As Boolean)
        
       Dim boTables As CrystalDecisions.ReportAppServer.DataDefModel.ISCRTables

        If issubrpt Then
            boTables = lcr.SubreportController.GetSubreport(srp).DatabaseController.Database.Tables
        Else
            boTables = lcr.DatabaseController.Database.Tables
        End If

        For Each Table As CrystalDecisions.ReportAppServer.DataDefModel.ISCRTable In boTables
            'Dateiname für Tabellendefinition erzeugen
            Dim XMLFile As String
            XMLFile = destination
            XMLFile &= "_R_" & srp
            XMLFile &= "_T_" & Table.Name.Trim & ".xml"

            'Tabellendefinition lesen und in Datei schreiben
            Dim dt As New DataTable

            For Each field As CrystalDecisions.ReportAppServer.DataDefModel.Field In Table.DataFields
                Dim fieldtype As String = ""
                Select Case field.Type
                    Case FieldValueType.BitmapField, FieldValueType.BlobField, FieldValueType.IconField, FieldValueType.OleField, FieldValueType.PictureField
                        fieldtype = "System.Byte[]"

                    Case FieldValueType.BooleanField
                        fieldtype = "System.Boolean"

                    Case FieldValueType.CurrencyField, FieldValueType.NumberField
                        fieldtype = "System.Decimal"

                    Case FieldValueType.TimeField, FieldValueType.DateField, FieldValueType.DateTimeField
                        fieldtype = "System.DateTime"

                    Case FieldValueType.Int16sField, FieldValueType.Int16uField, FieldValueType.Int32sField, FieldValueType.Int32uField, FieldValueType.Int8sField, FieldValueType.Int8uField
                        fieldtype = "System.Int32"

                    Case FieldValueType.StringField
                        fieldtype = "System.String"

                    Case Else
                        fieldtype = "System.String"

                End Select
                 dt.Columns.Add(New DataColumn(field.Name, Type.GetType(fieldtype)))
            Next

            dt.TableName = Table.QualifiedName
            Dim ds As New System.Data.DataSet

            ds.Tables.Add(dt)
            ds.WriteXml(XMLFile, XmlWriteMode.WriteSchema)

            'boMainPropertyBag: These hold the attributes of the tables ConnectionInfo object
            Dim boMainPropertyBag As New PropertyBag()
            'boInnerPropertyBag: These hold the attributes for the QE_LogonProperties
            'In the main property bag (boMainPropertyBag)
            Dim boInnerPropertyBag As New PropertyBag()

            'Set the attributes for the boInnerPropertyBag
            boInnerPropertyBag.Add("File Path", XMLFile)
            boInnerPropertyBag.Add("Internal Connection ID", Guid.NewGuid.ToString)

            'Set the attributes for the boMainPropertyBag
            boMainPropertyBag.Add("Database DLL", "crdb_adoplus.dll")
            boMainPropertyBag.Add("QE_DatabaseName", "")
            boMainPropertyBag.Add("QE_DatabaseType", "ADO.NET (XML)")

            'Add the QE_LogonProperties we set in the boInnerPropertyBag Object
            boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag)
            boMainPropertyBag.Add("QE_ServerDescription", "NewDataSet")
            boMainPropertyBag.Add("QE_SQLDB", "False")
            boMainPropertyBag.Add("SSO Enabled", "False")

            'Create a new ConnectionInfo object
            Dim boConnectionInfo As New CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo()
            'Pass the database properties to a connection info object
            boConnectionInfo.Attributes = boMainPropertyBag

            'Set the connection kind
            boConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE
 
            Dim boTable As CrystalDecisions.ReportAppServer.DataDefModel.ISCRTable
            boTable = Table.Clone(True)
            boTable.ConnectionInfo = boConnectionInfo

            Try
                If issubrpt Then
                    lcr.SubreportController.GetSubreport(srp).DatabaseController.SetTableLocation(Table, boTable)
                    lcr.VerifyDatabase()
                Else

                    lcr.DatabaseController.SetTableLocationEx(Table, boTable)
                    lcr.VerifyDatabase()
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        Next
  End Sub

former_member183750
Active Contributor
0 Kudos

Why not just pass an ADO .NET dataset to the TTX based report? As long as the dataset matches precisely the data definition as per the TTX file, it should work. See [this|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/18897] [original link is broken] [original link is broken] [original link is broken]; blog.

Alternatively, see KB [1553921 - Is there a utility that would help in writing database logon code?|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333533353333333933323331%7D.do].

Open the XML based report in the above utility and see the code needed to use the connection. Then try to use that same connection code for your TTX based report.

Ludek

Follow us on Twitter http://twitter.com/SAPCRNetSup

Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

jrgen_bauer2
Explorer
0 Kudos

Hi Ludek

Pushing an Dataset to an report is what I do. Please have a look at

I use an compatible Dataset and push it to the report. This works in 32 bit but not in 64 bit mode.

And because I have hundreds of Reports, which I don't want to convert manually, I tried to write a programm using the embeeded RAS functionality.

Jürgen

former_member183750
Active Contributor
0 Kudos

On the post you quote, I also suggested possible reason for the issue and a test. It may be a good idea to stick with either this thread or the other tread and close one or the other. Right now, I feel like a ping pong ball...

- Ludek

jrgen_bauer2
Explorer
0 Kudos

Hi Ludek

The thread I quoted is actualy closed (it was from march before your holidays) : I didn't get an answere on my last message so I opend a new one.

I even was not the original author.

My quote should tell you why i wrote this programm.

To your suggestions and tests:

Note 1525432 doesn't apply to me as my programm is in Framework 2

Note 1553921 Created the Connection Info in the same way as I created them in my program

Changing the Report with Designer from ttx to the created xml file from my Report worked with out problems. There were no notmatching fields.

As far as i can say now:

Passing an ADO .Net Dataset (System.Data.Dataset) to an TTX based report works only in 32 Bit and never in 64 Bit.

Jürgen

former_member183750
Active Contributor
0 Kudos

Ok. So after you pointed the report at the XML, save the report. Run it in the 64 bit app. Does that report work?

Just as a test...

- Ludek

jrgen_bauer2
Explorer
0 Kudos

Hi Ludek

Yes. Converted Report runs.

I changed my Program a little bit. Instead of SetTableLocation I use now the replaceConnection method. I Think this was may main fault.

But this works for ttx based reports only in 32Bit.

Here is my code:

Replace in the sub ConvertReportTables

Try
                If issubrpt Then
                    lcr.SubreportController.GetSubreport(srp).DatabaseController.SetTableLocation(Table, boTable)
                    lcr.VerifyDatabase()
                Else
                    lcr.DatabaseController.SetTableLocationEx(Table, boTable)
                    lcr.VerifyDatabase()
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

with

Try
                If issubrpt Then
                    lcr.SubreportController.GetSubreport(srp).DatabaseController.ReplaceConnection(Table.ConnectionInfo, boConnectionInfo, Nothing, CrystalDecisions.ReportAppServer.DataDefModel.CrDBOptionsEnum.crDBOptionDoNotVerifyDB)
                Else
                    lcr.DatabaseController.ReplaceConnection(Table.ConnectionInfo, boConnectionInfo, Nothing, CrystalDecisions.ReportAppServer.DataDefModel.CrDBOptionsEnum.crDBOptionDoNotVerifyDB)
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

Then save the report. The saved report is now based on XML not on TTX-files and can be used in 32 and 64Bit applications.

Maybe you could use my coding and make an Demoapplikation for other User which face the same Problem.

It can convert an Crystal Report which is based on any datasource to an XML-based Datssource.

Jürgen

former_member183750
Active Contributor
0 Kudos

Will do. Many thanks for posting your solution and sticking with this.

- Ludek

Answers (0)