|
-
Feb 28th, 2007, 11:01 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Setting DB location during codeing in CR 11
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
Code:
app.path & "\DB\data.mdb"
thanks
-
Mar 1st, 2007, 03:15 PM
#2
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
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...
-
Mar 2nd, 2007, 01:05 AM
#3
Re: Setting DB location during codeing in CR 11
if you are working in VB then read crystal report tutorial at my signature.
-
Mar 2nd, 2007, 01:23 AM
#4
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
hi
could not find an example where i can specify the database in codeing
please paste an example here.. thanks
-
Mar 2nd, 2007, 01:28 AM
#5
Re: Setting DB location during codeing in CR 11
-
Mar 2nd, 2007, 03:09 AM
#6
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
I did check that..
could not find any code which was showing a path to DB.. all are connecting to rpt..
-
Mar 2nd, 2007, 03:24 AM
#7
Re: Setting DB location during codeing in CR 11
Out you DB and the report at the
-
Mar 2nd, 2007, 03:28 AM
#8
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
so like
vb Code:
With CrystalReport1
.ReportFileName = App.Path & "\ReportName.rpt" & "\db\db.mdb"
-
Mar 2nd, 2007, 03:41 AM
#9
Re: Setting DB location during codeing in CR 11
 Originally Posted by khandu
so like
vb Code:
With CrystalReport1
.ReportFileName = App.Path & "\ReportName.rpt" & "\db\db.mdb"
No post your whole code
-
Mar 2nd, 2007, 05:35 AM
#10
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
Last edited by khandu; Mar 21st, 2007 at 02:54 PM.
-
Mar 2nd, 2007, 05:52 AM
#11
Re: Setting DB location during codeing in CR 11
-
Mar 2nd, 2007, 06:00 AM
#12
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
VB 6.0
i got the above code help from another person..
please help with the DB path
-
Mar 2nd, 2007, 06:05 AM
#13
Re: Setting DB location during codeing in CR 11
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
-
Mar 2nd, 2007, 06:17 AM
#14
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
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
-
Mar 4th, 2007, 11:43 AM
#15
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
Hi
Some help here Shakti please.. show me what codes to add on top to define "app.path & "/db/db.mdb"
thanks
-
Mar 5th, 2007, 06:27 AM
#16
Re: Setting DB location during codeing in CR 11
Tell me what are you using in your project DSN or connectionstring
-
Mar 5th, 2007, 09:21 AM
#17
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
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
-
Mar 6th, 2007, 08:17 PM
#18
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
-
Mar 10th, 2007, 07:30 AM
#19
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
shakti
please help out
how to mention to pick db from app.path & "\asd\db.mdb"
please help here..
-
Mar 10th, 2007, 01:40 PM
#20
Re: Setting DB location during codeing in CR 11
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
Code:
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.
-
Mar 10th, 2007, 02:37 PM
#21
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
the method
.setlocation is not showing in the CR 11
-
Mar 10th, 2007, 05:28 PM
#22
Re: Setting DB location during codeing in CR 11
.SetLocation was just my guess for the method name.
What other methods are there in CR 11? You are allowed to think for yourself...
-
Mar 11th, 2007, 10:16 AM
#23
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
cannot find any such method for it..
-
Mar 11th, 2007, 10:53 AM
#24
Re: Setting DB location during codeing in CR 11
According to the online documentation, use the SetTableLocation method, Location property or the ConnectionProperties property of the DatabaseTable object.
-
Mar 11th, 2007, 11:45 AM
#25
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
I tried this.. i use DAO for connection to DB in the project
vb Code:
For Each crxDatabaseTable In crxDatabaseTables
crxDatabaseTable.SetDataSource App.Path & "\database\db.mdb"
Next
Gave the error
Code:
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])
-
Mar 11th, 2007, 12:04 PM
#26
Re: Setting DB location during codeing in CR 11
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?
Code:
For Each crxDatabaseTable In crxDatabaseTables
crxDatabaseTable.Location App.Path & "\database\db.mdb"
Next
http://devlibrary.businessobjects.co.../en/devlib.htm
Last edited by brucevde; Mar 11th, 2007 at 12:10 PM.
-
Mar 11th, 2007, 12:46 PM
#27
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
well, it says invalid use of property for above also..
man..
-
Mar 11th, 2007, 11:10 PM
#28
Re: Setting DB location during codeing in CR 11
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.co...0.html#1686406
-
Mar 12th, 2007, 09:34 AM
#29
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
I tried as suggested.. still the same error
Object variable or With block variable not set (Error 91)
on the above mentioned line..
-
Mar 13th, 2007, 12:19 PM
#30
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
*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
-
Mar 16th, 2007, 03:22 PM
#31
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
-
Mar 21st, 2007, 12:32 PM
#32
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
*bump* please help someone..
-
Mar 21st, 2007, 12:39 PM
#33
Re: Setting DB location during codeing in CR 11
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
-
Mar 21st, 2007, 01:00 PM
#34
Re: Setting DB location during codeing in CR 11
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:
vb Code:
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:
vb Code:
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.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Mar 21st, 2007, 01:44 PM
#35
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
error is mentioned on top
Last edited by khandu; Mar 21st, 2007 at 02:57 PM.
-
Mar 21st, 2007, 02:04 PM
#36
Re: Setting DB location during codeing in CR 11
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
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Mar 21st, 2007, 02:11 PM
#37
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
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..
Last edited by khandu; Mar 21st, 2007 at 02:55 PM.
-
Mar 21st, 2007, 02:25 PM
#38
Re: Setting DB location during codeing in CR 11
Use the following code but place it after the report is opened, ie after
Set crxReport = crxApp.OpenReport(reportname)
Code:
Set crxDatabaseTables = crxReport.Database.Tables
For Each crxDatabaseTable In crxDatabaseTables
crxDatabaseTable.Location = App.Path & "\database\db.mdb"
Next
-
Mar 21st, 2007, 02:50 PM
#39
Thread Starter
Addicted Member
Re: Setting DB location during codeing in CR 11
excellent.. repped and FINALLY RESOLVED!!!!
will put that code after all the report call..
THANKS A LOT!!
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
|