Showing posts with label dim. Show all posts
Showing posts with label dim. Show all posts

Tuesday, March 20, 2012

crystal reports (urgent)

Public crxapplication As CRAXDRT.Application
Public crxreport As CRAXDRT.Report

Dim strReportName As String
Dim Fltr
crxapplication = New CRAXDRT.Application

'Pass the reportname to string variable
strReportName = "CITIES"

'Get the Report Location
Dim strReportPath As String = "C:\ReportViwer\ReportViwer" & "\" & strReportName & ".rpt"
'Check file exists
If Not IO.File.Exists(strReportPath) Then
Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))
End If
crxreport = crxapplication.OpenReport(strReportPath)
crxreport.DiscardSavedData()

'Delete all the original parameter values from the parameter picklist.
'If you want to keep the orginal parameter values in the parameter picklist, comment out this loop.
Do Until crxreport.ParameterFields(1).NumberOfDefaultValues = 0
crxreport.ParameterFields(1).DeleteNthDefaultValue(1)
Loop
crxreport.Database.Tables(1).SetDataSource(RS, 3)
' Read the records to force the parameter box to appear before sending data to the viewer
crxreport.ReadRecords()
Fltr = "{CITY_CITIES.COUNTRY_NO}={?COUNTRY_NO}"
' Get the value the user enters in the parameter box then send that text to the formula field (that ' the report is grouped on)
crxreport.RecordSelectionFormula = Fltr
' View the report
AxCrystalActiveXReportViewer1.ViewReport()
End Sub

The error I am getting is An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in axinterop.crystalactivexreportviewerlib10.dll

Additional information: Unspecified error

Can I have your help please.Which line are you getting the error?

Thursday, March 8, 2012

crystal report and oracle?

I have a little VB.net web application which connects to Oracle using ADO.NET so i make connection

Dim Oraclecon As OleDbConnection = New OleDbConnection("Provider=MSDAORA.1;Data Source=name;Password=pass;User ID=name;")

and all work good till i try to use crystal report. it generate exception(it happens when i do report.export) "CrystalDecisions.CrystalReports.Engine.LogOnException: logon failed".
in msdn i found article "Accessing Secure Databases" with such a code

' Declare require variables.
Dim logOnInfo As New TableLogOnInfo()
Dim i As Integer

' Loop through every table in the report.
For i = 0 To report.Database.Tables.Count - 1
' Set the connection information for current table.
logOnInfo.ConnectionInfo.ServerName = serverNameTxt.Text
logOnInfo.ConnectionInfo.DatabaseName = dbNameTxt.Text
logOnInfo.ConnectionInfo.UserID = userNameTxt.Text
logOnInfo.ConnectionInfo.Password = passwordTxt.Text
report.Database.Tables.Item(i).ApplyLogOnInfo(logOnInfo)
Next i

i suppose servername parameter should be equal Data Source in connection string and DatabaseName should be empty but it still don't work. and frankly speaking i don't understand why crystal report should know logon information if i use in my report ado.net dataset as data source and make connection to oracle through ado.net technology. why should i logon twice?? so if someone had such problems please help any advice will be usefulHi,

Maybe this can help you because I also use Oracle under SCO UNIX and works for me.

1. You need to have a CrystalReport control in your form.
2. Assign to that control a name (myControl, v.g.).
3. Declare two strings variables (strSQL and strCon, v.g.).
4. Make your SQL sentence for criteria that will be throw to Crystal Reports.
Example:

strSQL = "{mytable.cycle} = 2004"

This line will added to the SQL sentence formed by Crystal Reports when you make your report. Note: this can be optional.


5. Connection for Crystal Reports. This example applies to Oracle where server is a service name made with Easy Configuration of your Oracle Client software.
strCon = "DSN =server;UID=user;PWD=password;"

User: user of Oracle
Password: which is necessary to connect to Oracle

6. Finally, properties to connect to Crystal Reports and view your report.


myControl.ReportFileName = app.path & "\Test.rpt"
myControl.Connect = strCon
myControl.SelectionFormula = strSQL
myControl.Action = 1

I hope this can serve you.

Xernai.

Wednesday, March 7, 2012

Crystal Error

HI ,

I'm trying to print a rpt. file ( C.R. 8.5) from a VB.net program
code :

Dim Reporte As New crAlmacen
Dim x As String = Reporte.FilePath()
Dim x1 As String = Reporte.ResourceName
Reporte.SetDatabaseLogon("termi", "termi", "SERVIDOR1", "mestres")
Reporte.Refresh()
' Reporte.PrintOptions.PrinterName = "Lexmark Optra S 2455"

Reporte.PrintToPrinter(1, False, 1, 1)

An unhandled exception of type 'CrystalDecisions.CrystalReports.Engine.InvalidArgumentException' occurred in crystaldecisions.crystalreports.engine.dll

Additional information: Error in File C:\DOCUME~1\ADMINI~1\CONFIG~1\Temp\temp_50488d2a-21be-4a5a-a4df-ad83112d6274.rpt:
Invalid printer specified.

thanks a lotHI ,

I HAVE SOLVED THE PROBLEM

Dim Reporte As New crAlmacen
Dim x As String = Reporte.FilePath()
Dim x1 As String = Reporte.ResourceName
Reporte.SetDatabaseLogon("termi", "termi", "SERVIDOR1", "mestres")
Reporte.Refresh()

NEW CODE LINE
---------------------
Reporte.PrintOptions.PaperSource = CrystalDecisions.[Shared].PaperSource.Auto
---------------------
' Reporte.PrintOptions.PrinterName = "Lexmark Optra S 2455"
Reporte.PrintToPrinter(1, False, 1, 1)

AND NOW GO RIGHT

BEST REGARDS|||Glad that's sorted :D