Click to See Complete Forum and Search --> : [RESOLVED] Setting DB location during codeing in CR 11
khandu
Feb 28th, 2007, 10:01 AM
Hi
While making a report in CR11 we specify the DB
But What if I wanna specify the DB during codeing..
How do i do that.. the DB is in location
app.path & "\DB\data.mdb"
thanks
khandu
Mar 1st, 2007, 02:15 PM
please help..
because what is happening.. when i create an installer and run the prog.. then the viewer asks for path again because the specified path during design time is not the same as the installed path.. so this can be a lot of problem...
shakti5385
Mar 2nd, 2007, 12:05 AM
if you are working in VB then read crystal report tutorial at my signature.
khandu
Mar 2nd, 2007, 12:23 AM
hi
could not find an example where i can specify the database in codeing
please paste an example here.. thanks
shakti5385
Mar 2nd, 2007, 12:28 AM
http://vbforums.com/showthread.php?p=2645742
khandu
Mar 2nd, 2007, 02:09 AM
I did check that..
could not find any code which was showing a path to DB.. all are connecting to rpt..
shakti5385
Mar 2nd, 2007, 02:24 AM
Out you DB and the report at the App.Path
khandu
Mar 2nd, 2007, 02:28 AM
so like
With CrystalReport1
.ReportFileName = App.Path & "\ReportName.rpt" & "\db\db.mdb"
shakti5385
Mar 2nd, 2007, 02:41 AM
so like
With CrystalReport1
.ReportFileName = App.Path & "\ReportName.rpt" & "\db\db.mdb"
No post your whole code
khandu
Mar 2nd, 2007, 04:35 AM
not working on code
shakti5385
Mar 2nd, 2007, 04:52 AM
are you using VB.NET
khandu
Mar 2nd, 2007, 05:00 AM
VB 6.0
i got the above code help from another person..
please help with the DB path
shakti5385
Mar 2nd, 2007, 05:05 AM
But What if I wanna specify the DB during codeing..
No need
use the DB Path in the connection USE the DSN for the report.
I make report In the VB 6.0 using the DSN not the DB Path
I suggest you that if you are using the connection string in the project then use the DSN
ans make report using the DSN
Then they call automaticallly
khandu
Mar 2nd, 2007, 05:17 AM
Hi i m totally new to this
can u explain exactly what to do in the report..
this is how i do in the design
http://img296.imageshack.us/img296/2520/daoxc7.th.gif (http://img296.imageshack.us/my.php?image=daoxc7.gif)
khandu
Mar 4th, 2007, 10:43 AM
Hi
Some help here Shakti please.. show me what codes to add on top to define "app.path & "/db/db.mdb"
thanks
shakti5385
Mar 5th, 2007, 05:27 AM
Tell me what are you using in your project DSN or connectionstring
khandu
Mar 5th, 2007, 08:21 AM
as i showed u the code on top..
I designed a rpt in CR11 directly and gave a direct connection to it and picked up fields from there.. so its always asking for that path which i gave from browse.. i think its DSN..
the pic above shows i gave a direct connection
khandu
Mar 6th, 2007, 07:17 PM
bump.. help plz
khandu
Mar 10th, 2007, 06:30 AM
shakti
please help out
how to mention to pick db from app.path & "\asd\db.mdb"
please help here..
brucevde
Mar 10th, 2007, 12:40 PM
I have never used CR 11 but the CRAXDRT of prior versions all have a method that lets you specify the database location of every table. Something like
For Each DatabaseTable in DatabaseTables
DatabaseTable.SetLocation App.Path & "\Data\Database.mdb"
Next
I don't access to Crystal right now so cannot confirm the actual method names. Anyways, use the help file or object browser to find the object/method you need to call.
khandu
Mar 10th, 2007, 01:37 PM
the method
.setlocation is not showing in the CR 11
brucevde
Mar 10th, 2007, 04:28 PM
.SetLocation was just my guess for the method name.
What other methods are there in CR 11? You are allowed to think for yourself...
khandu
Mar 11th, 2007, 10:16 AM
cannot find any such method for it.. :(
brucevde
Mar 11th, 2007, 10:53 AM
According to the online documentation, use the SetTableLocation method, Location property or the ConnectionProperties property of the DatabaseTable object.
khandu
Mar 11th, 2007, 11:45 AM
I tried this.. i use DAO for connection to DB in the project
For Each crxDatabaseTable In crxDatabaseTables
crxDatabaseTable.SetDataSource App.Path & "\database\db.mdb"
Next
Gave the error
Run time error 424 Object required
This is the syntax showing for setdatasource
SetDataSource Method (Database Object)
The SetDataSource method is used to provide information about a data source to the database driver associated with this Database object at runtime. For instance, if a report has been designed using the Crystal Active Data Driver this method can be used to provide an active data source for the report, such as a DAO, ADO, or RDO Recordset or a CDO Rowset. In this case, the object passed to the second parameter of this method replaces, at runtime, the field definition file used to create the report. This method can be invoked only in formatting Idle mode. When using a secure connection such as SQL Server, some additional code is required
Syntax
Sub SetDataSource (data, [dataTag], [tableNumber])
brucevde
Mar 11th, 2007, 12:04 PM
The SetDataSource method expects an object, like a DAO.Recordset or ADO.Recordset, not the path to a database file. Are you trying to pass a DAO.Recordset to the report?
For Each crxDatabaseTable In crxDatabaseTables
crxDatabaseTable.Location App.Path & "\database\db.mdb"
Next
http://devlibrary.businessobjects.com/BusinessObjectsXI/en/devlib.htm
khandu
Mar 11th, 2007, 12:46 PM
well, it says invalid use of property for above also..
man..
brucevde
Mar 11th, 2007, 11:10 PM
crxDatabaseTable.Location = App.Path & "\database\db.mdb"
Did you even try looking at the documentation? A little browsing and you would've found
http://devlibrary.businessobjects.com/BusinessObjectsXI/en/en/RDC_SDK/rdc_com_dg_doc/doc/rdcsdk_com_doc/RDC_ObjectModel260.html#1686406
khandu
Mar 12th, 2007, 09:34 AM
I tried as suggested.. still the same error
Object variable or With block variable not set (Error 91)
on the above mentioned line..
khandu
Mar 13th, 2007, 12:19 PM
*bump*
can some1 please upload a small proj here showing how to select manual location of DB for CR11 reports in VB6 during runtime..
thanks
khandu
Mar 16th, 2007, 03:22 PM
*bump*
khandu
Mar 21st, 2007, 12:32 PM
*bump* please help someone..
brucevde
Mar 21st, 2007, 12:39 PM
I don't understand why the link posted earlier does not help you. I don't have CR11 so cannot create a sample app. Post your modified code...
http://devlibrary.businessobjects.co...0.html#1686406
GaryMazzone
Mar 21st, 2007, 01:00 PM
This is what I use to do CRXI with VB6
On a form that hold the ReportVeiwer do the following:
In the Declations section of the form:
Private m_App As New CRAXDDRT.Application
Private m_Rep As New CRAXDDRT.Report
Public mRepName As String
Public mstrW As String
Public mstrUName As String
Public msRepTitle As String
Public mstrRef As String
Public mstrC3 As String
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Now create a sub Named DisplayReport:
Public Sub DisplayReport()
Dim ConnectionInfo As CRAXDDRT.ConnectionProperties
Dim strPNameP As String
Dim test As String
Set m_Rep = Nothing
strPNameP = mRepName
mRepName = App.Path & "\" & mRepName
test = gstrDBLoc & "\" & gstrDBName
Set m_Rep = m_App.OpenReport(mRepName, 1)
If strPNameP = "RempRep1.rpt" Then
m_Rep.RecordSelectionFormula = m_Rep.RecordSelectionFormula & mstrW
ElseIf strPNameP = "RempRep1_HB.rpt" Then
m_Rep.RecordSelectionFormula = m_Rep.RecordSelectionFormula & mstrW
ElseIf strPNameP = "RempRep2.rpt" Then
m_Rep.RecordSelectionFormula = m_Rep.RecordSelectionFormula & mstrW
ElseIf strPNameP = "RempRep2_HB.rpt" Then
m_Rep.RecordSelectionFormula = m_Rep.RecordSelectionFormula & mstrW
Else
m_Rep.RecordSelectionFormula = mstrW
End If
Set ConnectionInfo = m_Rep.Database.Tables(1).ConnectionProperties
On Error Resume Next
m_Rep.Database.Tables(1).DllName = "crdb_dao.dll"
ConnectionInfo.DeleteAll
ConnectionInfo.Add "Database Name", test
ConnectionInfo.Add "Session UserID", "Report"
ConnectionInfo.Add "Session Password", ""
ConnectionInfo.Add "System Database Path", gstrDBLoc & "\Security.mdw"
If strPNameP = "FSSResultsbyNuclide(Area)_New.rpt" Then
m_Rep.ReportTitle = "Sample Results by Rank"
ElseIf strPNameP = "FSSSamplesforAreaDetail_New.rpt" Then
m_Rep.ReportTitle = "Sample Analysis Results by Area"
ElseIf strPNameP = "DataFrequencyPlot.rpt" Then
m_Rep.ReportTitle = "Data Frequency Plot for " & fRepGen.cboIsotopes.Text
ElseIf strPNameP = "E600SurveysinArea.rpt" Then
m_Rep.ReportTitle = msRepTitle
ElseIf strPNameP = "DataQuantPlot.rpt" Then
m_Rep.ReportTitle = "Data Quantile Plot for " & fRepGen.cboIsotopes.Text
ElseIf strPNameP = "AreaComps.rpt" Then
m_Rep.EnableParameterPrompting = False
m_Rep.ParameterFields(1).AddCurrentValue (mstrRef)
m_Rep.ParameterFields(2).AddCurrentValue (Me.mstrC3)
ElseIf strPNameP = "RempRep1.rpt" Then
m_Rep.EnableParameterPrompting = False
m_Rep.ParameterFields(1).AddCurrentValue mstrC3
ElseIf strPNameP = "RempRep1_HB.rpt" Then
m_Rep.EnableParameterPrompting = False
m_Rep.ParameterFields(1).AddCurrentValue mstrC3
ElseIf strPNameP = "RempRep2.rpt" Then
m_Rep.EnableParameterPrompting = False
m_Rep.ParameterFields(1).AddCurrentValue mstrC3
ElseIf strPNameP = "RempRep2_HB.rpt" Then
m_Rep.EnableParameterPrompting = False
m_Rep.ParameterFields(1).AddCurrentValue mstrC3
End If
crView.ReportSource = m_Rep
Sleep 2000
crView.ViewReport
'crView.Zoom 1
If strPNameP = "AreaComps.rpt" Then
m_Rep.ParameterFields.Delete (1)
m_Rep.ParameterFields.Delete (2)
ElseIf strPNameP = "RempRep1.rpt" Then
m_Rep.ParameterFields.Delete (1)
ElseIf strPNameP = "RempRep1_HB.rpt" Then
m_Rep.ParameterFields.Delete (1)
ElseIf strPNameP = "RempRep2.rpt" Then
m_Rep.ParameterFields.Delete (1)
ElseIf strPNameP = "RempRep2_HB.rpt" Then
m_Rep.ParameterFields.Delete (1)
End If
Set m_Rep = Nothing
End Sub
That is called from the print but on the form I have to generate the reports. This use a security database and uses group security. But you should get the basic idea of how to do this here.
khandu
Mar 21st, 2007, 01:44 PM
error is mentioned on top
GaryMazzone
Mar 21st, 2007, 02:04 PM
What Error? At the top of what?
Did you include the references for Crystal as follows:
Crystal Reports Viewer Library 11.0
Crystal Reports ActiveX Designer Design and Runtime Library 11.0
Crystal Reports Activex Designer Runtime Library 11.0
khandu
Mar 21st, 2007, 02:11 PM
yes.. all the runtime are included
I get the error on the line
For Each crxDatabaseTable In crxDatabaseTables
Runtime 424 Object required
some1 please modify the above code so that i can mention the DB location at runtime for the reports..
brucevde
Mar 21st, 2007, 02:25 PM
Use the following code but place it after the report is opened, ie after
Set crxReport = crxApp.OpenReport(reportname)
Set crxDatabaseTables = crxReport.Database.Tables
For Each crxDatabaseTable In crxDatabaseTables
crxDatabaseTable.Location = App.Path & "\database\db.mdb"
Next
khandu
Mar 21st, 2007, 02:50 PM
excellent.. repped and FINALLY RESOLVED!!!!
will put that code after all the report call..
THANKS A LOT!!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.