|
-
Oct 27th, 2005, 10:08 AM
#1
Thread Starter
New Member
[RESOLVED] Changing Datasource in VB6 using Crystal
I am trying to change the datasource for a crystal report in VB6 and it still looks at the report datasource when it was built. I am trying to use the code
report.database.setdatasource e:\ware.mdb,3,1
It is still trying to find it in the old location when the report was built.
e:\ware\ware.mdb
I am trying to change this on the fly so that I can place the database anywhere and just change the location in an INI file which the VB program reads on startup.
Thanks.
Last edited by randy1227; Oct 27th, 2005 at 11:07 AM.
Randy1227
-
Oct 27th, 2005, 10:21 AM
#2
Re: Changing Datasource in VB6 using Crystal
I dont think you can pass the mdb location for the datasource. You need to pass an ADO recordset as the Datasource like you posted. Check my example in my signature - VB6/CR Ex.
Moved from Classic VB forum.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 27th, 2005, 10:37 AM
#3
Re: Changing Datasource in VB6 using Crystal
Welcome to the forums. 
You need to pass the a recordset as Rob indicates.
-
Oct 27th, 2005, 10:46 AM
#4
Thread Starter
New Member
Re: Changing Datasource in VB6 using Crystal
 Originally Posted by RobDog888
I dont think you can pass the mdb location for the datasource. You need to pass an ADO recordset as the Datasource like you posted. Check my example in my signature - VB6/CR Ex.
Moved from Classic VB forum.
Your code did not show up. could you please post it.
-
Oct 27th, 2005, 10:50 AM
#5
Re: Changing Datasource in VB6 using Crystal
Maybe you have a popup blocker? Anyways here is a copy of the links code.
VB Code:
Option Explicit
'Add reference to Crystal Reports x.x ActiveX Designer RunTime Library
'Add reference to Crystal Reports Viewer Control
'Add reference to Microsoft ActiveX Data Objects 2.x Library
'oCnn = current open ADO connection object
Private Sub Command1_Click()
Dim oApp As CRAXDRT.Application
Dim oReport As CRAXDRT.Report
Dim oRs As ADODB.Recordset
Dim sSQL As String
sSQL = "SELECT * FROM Table1"
Set oRs = New ADODB.Recordset
Set oRs = oCnn.Execute(sSQL)
Set oApp = New CRAXDRT.Application
Set oReport = oApp.OpenReport(App.Path & "\MyReport.rpt", 1)
oReport.Database.SetDataSource oRs, 3, 1 '<--Pass an ADO Recordset here
crvMyCRViewer.ReportSource = oReport
crvMyCRViewer.ViewReport
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 28th, 2005, 07:56 AM
#6
New Member
Re: [RESOLVED] Changing Datasource in VB6 using Crystal
Ok, What if we want to change the whole SQL database ? Preferable using ODBC connection?
e.g If design time used Connection "ODBC1" and on run time it should use "ODBC2"? I am using CR XI.
Thanks.
-
Oct 30th, 2005, 12:16 PM
#7
Member
Re: Changing Datasource in VB6 using Crystal
 Originally Posted by RobDog888
Maybe you have a popup blocker? Anyways here is a copy of the links code.
VB Code:
Option Explicit
'Add reference to Crystal Reports x.x ActiveX Designer RunTime Library
'Add reference to Crystal Reports Viewer Control
'Add reference to Microsoft ActiveX Data Objects 2.x Library
How do I do this??!?!?!? I can't figure it out, PLEASE HELP!
-
Oct 30th, 2005, 12:29 PM
#8
Re: [RESOLVED] Changing Datasource in VB6 using Crystal
For line 1 and 3...
Project > References... > check/select each reference > click Ok.
For line 2...
Project > Components > Controls tab > check/select CR Viewer Control > click OK.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 31st, 2005, 08:50 AM
#9
Re: [RESOLVED] Changing Datasource in VB6 using Crystal
I change the database location of Crystal reguarly using VB and Aceess databases. It wis different between verison 8 of Crystal and versions newer then that. If you would like an example let me know and I' post them.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Oct 31st, 2005, 08:17 PM
#10
Member
Re: [RESOLVED] Changing Datasource in VB6 using Crystal
 Originally Posted by GaryMazzone
I change the database location of Crystal reguarly using VB and Aceess databases. It wis different between verison 8 of Crystal and versions newer then that. If you would like an example let me know and I' post them.
If you could post examples that would help out a ton!
-
Nov 9th, 2005, 03:00 AM
#11
Addicted Member
Re: [RESOLVED] Changing Datasource in VB6 using Crystal
hi... how about changing datasources using data report? does anybody know?? pls help??
-
Nov 15th, 2005, 11:18 AM
#12
Member
Re: [RESOLVED] Changing Datasource in VB6 using Crystal
 Originally Posted by GaryMazzone
I change the database location of Crystal reguarly using VB and Aceess databases. It wis different between verison 8 of Crystal and versions newer then that. If you would like an example let me know and I' post them.
I have been working on this for over two months now and can't figure it out if you could post examples that would be great. I have tried EVERYTHING!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|