cancel
Showing results for 
Search instead for 
Did you mean: 

How change connection form MSAccess to SQL Server programatically?

Former Member
0 Kudos

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

mireport.Load("\report1.rpt")

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)

CrTable.ApplyLogOnInfo(CrtableLogoninfo)

If Tipo_Base_Datos = "SQL" Then CrTable.Location = "bdsql".dbo." & CrTable.Location.Substring(CrTable.Location.LastIndexOf(".") + 1)

Next

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Fernando,

please download ready samples how to change database at runtime

[Csharp .NET Windows Sample apps|https://smpdl.sap-ag.de/~sapidp/012002523100006252722008E/csharp_win_smpl.exe]

[VB .NET Windows Sample apps|https://smpdl.sap-ag.de/~sapidp/012002523100006252822008E/net_win_smpl.exe]

[CR .NET SDK - Sample apps from Tutorials|https://smpdl.sap-ag.de/~sapidp/012002523100006252702008E/cr_net_sdk_tutorials_en.zip]

[CR for .NET - Walkthrough Support Files|https://smpdl.sap-ag.de/~sapidp/012002523100005853792008E/walkthrough_supportfiles.zip]

[More samples|https://boc.sdn.sap.com/dotnet/samples]

Best regards

Falk

Answers (1)

Answers (1)

Former Member
0 Kudos

I'm not code found in your samples dear Falk Liebezeit, but, i found a solution in the thread

[;

The answer is now, How change datasource location and type for the subreports?

Thanks for your help.