on 09-01-2008 9:11 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.