Same rpt Crystal Report connect MSAccess and SQL Server. It's possible? RRS feed

  • Question

  • I have an rpt designed to accede to an MSAccess Database, everything works.

    Now, I need change by programming the connection to against an access Database SQL Server that it possesses the same structure that access database .

    The question is How I can that change?

    Said differently, is there some way to change for code the connection of file Crystal Report of access to SQL Server?

    VB.NET 2005
    CR XI Relase 2 sp 4

    My code, wrong:

    Dim mireport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
    Dim logoninfo As New CrystalDecisions.Shared.TableLogOnInfo
    Dim tlogoninfos As New CrystalDecisions.Shared.TableLogOnInfos
    Dim connectionInfo As New CrystalDecisions.Shared.ConnectionInfo

    Dim CrtableLogoninfos As New CrystalDecisions.Shared.TableLogOnInfos()
    Dim CrtableLogoninfo As New CrystalDecisions.Shared.TableLogOnInfo()
    Dim CrConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo()
    Dim CrTables As CrystalDecisions.CrystalReports.Engine.Tables
    Dim CrTable As CrystalDecisions.CrystalReports.Engine.Table


    With CrConnectionInfo
    If Tipo_Base_Datos = "SQL" Then
    .ServerName = "server"
    .DatabaseName = "bdsql"
    .UserID = ""
    .Password = ""
    .IntegratedSecurity = True
    End If

    If Tipo_Base_Datos = "ACCESS" Then
    .ServerName = "c:\bd.mdb"
    .DatabaseName = "c:\bd.mdb"
    .UserID = ""
    .Password = ""
    End If
    End With

    CrTables = mireport.Database.Tables

    For Each CrTable In CrTables
    CrtableLogoninfo = CrTable.LogOnInfo
    CrtableLogoninfo.ConnectionInfo = CrConnectionInfo
    'MsgBox(crtableLogoninfo.ConnectionInfo.ServerName & " " & crtableLogoninfo.ConnectionInfo.DatabaseName)
    If Tipo_Base_Datos = "SQL" Then CrTable.Location = "bdsql".dbo." & CrTable.Location.Substring(CrTable.Location.LastIndexOf(".") + 1)

    • Moved by jack 321 Tuesday, August 26, 2008 4:11 AM not a CR for VS edition issue (Moved from Crystal Reports for Visual Studio to Off-Topic Posts (Do Not Post Here))
    Friday, August 22, 2008 11:25 AM