|
-
Sep 23rd, 2005, 02:10 AM
#1
Re: error connecting password protected access database to crystal reports from visual ba
I've just discovered another way to do it:
VB Code:
Option Explicit
Dim Report As New CrystalReport1
[color=red]Dim crProp As CRAXDRT.ConnectionProperties[/color]
Private Sub Form_Load()
Screen.MousePointer = vbHourglass
[color=red]Set crProp = Report.Database.Tables(1).ConnectionProperties
crProp.Item("Database Name") = App.Path & "\mydb.mdb"
crProp.Item("Database Password") = "mypassword"[/color]
Report.RecordSelectionFormula = "{mytable.myfield}='condition'"
CRViewer91.ReportSource = Report
CRViewer91.ViewReport
Screen.MousePointer = vbDefault
End Sub
Download this document from the Crystal web site:
http://support.businessobjects.com/c...erties.pdf.asp
It explains it all pretty well.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Sep 23rd, 2005, 01:39 PM
#2
Thread Starter
Junior Member
Re: error connecting password protected access database to crystal reports from visual ba
dear pnish am facing a typical problem...
i successfully tried with the solution provided by you in connecting crystal reports: but since i was bogged by this for too long i tried solution from mazzard posted on this forum itself...
and am using selection formulae etc... in this method am making crystal reports in Crystal Report 9, again the database is secured one ...and am using Visual Basic 6.0, am connecting to reports made in crystal reports...by the following method...but when i make setup package to deploy it gives error if i try opening other report after opening any report once....it says memory referrenced click OK to terminate program and Cancel to debug it and package shuts downn.. i have used on error resume next too...i am not able to make out y this happening...u have a look at it and suggest if sthg can be done else i will make al reports via crystal report designer adding the reports already made but again then i will have problem of how to use the selection formulae which am using in this method on selection from list box and datetime picker...as i dont know how can we select and pass the formulae by the method of report designer.....and have done it this way after all my efforts as yesterday only was able to work well with the code given by u.. i had problem accessing secured database in crystal reports in my Visual Basic application i successfully did it after all the help from this forum now i am having this small problem
what i have done is that i used same line of code in all forms but changed the report source to report1 , report 2 , report3 respectively rest all lines are same
its running well in development envt but when i run it after installing the first report runs well while i click on next report it gives error memory referrenced ..click ok to terminate program or cancel to debug it..
plz help me where i am faltering..
i have added crystal reports report1 report 2 and report3 to my package as well while making deployment package...
help me its urgent
Private m_App As New CRAXDDRT.Application
Private m_Rep As New CRAXDDRT.Report
Public mRepName As String
Public mstrW As String
Dim strw As String
Public mstrUName As String
Public msRepTitle As String
Private Sub Command1_Click()
On Error Resume Next
If List1.Text = "" Then
MsgBox ("Select Job No")
Exit Sub
Else
If dtp1.Value = "" And dtp2.Value = "" Then
MsgBox ("Select Dates from two Calendars")
Exit Sub
Else
On Error Resume Next
'strW = "{assignjob.cusname} = '" & cboStudyAreas.Text & ""
''to use''''''''mstrW = "{ customerdetails.csno} = 9 "
Dim ConnectionInfo As CRAXDDRT.ConnectionProperties
Dim test As String
mRepName = App.Path & "\report1.rpt"
test = App.Path & "\ proj1.mdb"
Set m_Rep = m_App.OpenReport(mRepName, 1)
m_Rep.RecordSelectionFormula = mstrW
Dim nm As String
nm = List1.Text
Dim dt1 As String
Dim dt2 As String
dt1 = Format(dtp1.Value, "yyyy,mm,dd,0,0,0")
dt2 = Format(dtp2.Value, "yyyy,mm,dd,0,0,0")
strw = "{assignjob.jobno} = '" & List1.Text & "' and {assignjob.releaseddate} in DateTime (" & dt1 & ") to DateTime (" & dt2 & ")" ..........and other conditions too am using...
Set ConnectionInfo = m_Rep.Database.Tables(1).ConnectionProperties
'On Error Resume Next
m_Rep.Database.Tables(1).DllName = "crdb_dao.dll"
Set ConnectionInfo = m_Rep.Database.Tables(2).ConnectionProperties
m_Rep.Database.Tables(2).DllName = "crdb_dao.dll"
ConnectionInfo.DeleteAll
ConnectionInfo.Add "proj.mdb", test
ConnectionInfo.Add "session UserID", "admin"
ConnectionInfo.Add "Session Password", "dips"
Form1.mstrW = strw
List1.Visible = False
Command1.Visible = False
CRViewer91.ReportSource = m_Rep
'CRViewer91.Visible = True
Command2.Visible = True
CRViewer91.ViewReport
CRViewer91.Zoom 1
CRViewer91.Top = 0
CRViewer91.Left = 0
CRViewer91.Height = ScaleHeight
CRViewer91.Width = ScaleWidth
Set m_Rep = Nothing
End If
End If
End Sub
Private Sub Command2_Click()
main.Show
Unload Me
End Sub
Private Sub Form_Load()
On Error Resume Next
CRViewer91.Visible = False
Command2.Visible = False
Set cn = New ADODB.Connection
With cn
.Provider = "microsoft.jet.oledb.4.0"
.Properties("jet oledb:database password") = "dips"
.Open App.Path & "\proj.mdb"
End With
Set rs1 = New ADODB.Recordset
sql1 = "select distinct jobno from jobassign"
rs1.Open sql1, cn, adOpenDynamic, adLockOptimistic
List1.Visible = True
rs1.MoveFirst
Do Until rs1.EOF
List1.AddItem (rs1.Fields(0))
rs1.MoveNext
Loop
rs1.Close
cn.Close
End Sub
plz help me out.
thanks in advance
-
Sep 23rd, 2005, 08:21 PM
#3
Re: error connecting password protected access database to crystal reports from visual ba
I'm not sure if this has anything to do with your problem but the following:
VB Code:
Private m_App As New CRAXDDRT.Application
Private m_Rep As New CRAXDDRT.Report
should be:
VB Code:
Private m_App As New CRAXDRT.Application
Private m_Rep As New CRAXDRT.Report
Note the single D in CRAXDRT, not double D as you had it. Also make sure all references are set to Nothing when you've finished with them.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Sep 24th, 2005, 01:35 AM
#4
Thread Starter
Junior Member
Re: error connecting password protected access database to crystal reports from visual ba
Thanks pnish,
i have set m_rep= nothing, what all referrences do i need to set to nothing..
plz tell in detail as am worried....with this problem a lot.............
thanks
-
Sep 24th, 2005, 01:44 AM
#5
Thread Starter
Junior Member
Re: error connecting password protected access database to crystal reports from visual ba
ok i neeed to set M_App=Nothing too.......
thanks i will try this on my project make a setup exe and will let u know............
-
Oct 31st, 2005, 10:36 PM
#6
Member
Re: error connecting password protected access database to crystal reports from visual ba
 Originally Posted by pnish
crProp.Item("Database Name") = App.Path & "\mydb.mdb"
I tried this and it says that "Item" is read only
??
-
Oct 31st, 2005, 10:43 PM
#7
Re: error connecting password protected access database to crystal reports from visual ba
It must have changed from Crystal v9
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
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
|