Help Need Imediately, Refresh Report

M

Meena

Hi every Body,

I am using crystalReports 8.5 and vb.Net Could anyone help me to sort
out this problem.I couln't Refresh my report Using code.I am using
ODBC Connection.There is no option for me to change from ODBC.


I have tried to include the below code in my application.But it's not
working for me, its asking a pop up to loging again n even supplied
pwd n username its saying that unable to open.

Please help me out for solving this.Tried many ways n stuck @this
point from past few days.searched this kind of problem in groups but
didn't get a suitable one for me.Early Repliey is greatly appreciated.
:-(

Thank you,
Regards
meena.


'CR Variables
Dim crReportDocument As CrystalReport1
Dim crTableLogOnInfos As TableLogOnInfos
Dim crTableLogOnInfo As TableLogOnInfo
Dim crConnectionInfo As ConnectionInfo





'Create an instance of the strongly-typed report object
crReportDocument = New CrystalReport1()

'Setup the connection information structure to be used
'to log onto the datasource for the report.
crConnectionInfo = New ConnectionInfo()
With crConnectionInfo
.ServerName = "xxxx" 'physical server name
.DatabaseName = "Pubs"
.UserID = "sa"
.Password = ""
End With

'Define and set the logon information for the table
crTableLogOnInfo = New TableLogOnInfo()
With crTableLogOnInfo
.ConnectionInfo = crConnectionInfo
.TableName = "authors"
End With

'Pass the table info to a collection of tables.
crTableLogOnInfos = New TableLogOnInfos()
crTableLogOnInfos.Add(crTableLogOnInfo)

'Pass the entire collection of table logon information to the
viewer.
CrystalReportViewer1.LogOnInfo = crTableLogOnInfos

'Set the viewer to the report object to be previewed. This
must be done
'after all the database logon has been set.
CrystalReportViewer1.ReportSource = crReportDocument
 
G

Guest

Hope this helps, the code isn't .NET it's VB6 and I don't have time to convert it. If you are in a rush it should point you in the right direction. Don't forget you will also need to do this for each sub report

Parameters
Report is the crystal repor
kODBC is the ODBC to us
kDB is the database name on the server, don't know why Crystal wants bot

Sub ChangeConnection(Report As Object,
kODBC As String,
kDB As String,
Optional dblCrystalVersion As Double = 8.5
On Error GoTo ChangeConnection_Er
Dim strLocation As Strin
Dim CPProperties As Objec
Dim DBTable As Objec
Dim intLoop As Intege
Dim dt As Object, tmpStr As String, i As Intege
Dim CPPropery As Objec
Dim intTries As Intege

intTries =

' Repoint all tables in the report

For intLoop = 1 To Report.Database.Tables.Coun
If dblCrystalVersion = 8.5 The
Set dt = Report.Database.Tables(intLoop
dt.SetLogOnInfo kODBC, kDB, "sa", "
tmpStr = dt.Locatio
i = InStr(LCase$(tmpStr), ".dbo."
tmpStr = kDB & Mid$(tmpStr, i
dt.Location = tmpSt
Els
Set DBTable = Report.Database.Tables(intLoop
strLocation = DBTable.Locatio
' Get the collection of connection properties
Try_Again
Set CPProperties = DBTable.ConnectionPropertie

' Clear all the ConnectionProperty objects from the collection
For Each CPPropery In CPPropertie
If UCase(CPPropery.Name) = "DSN" Then CPPropery.Value = kODB
If UCase(CPPropery.Name) = "DATABASE" Then CPPropery.Value = kD
If UCase(CPPropery.Name) = "QUOTED ID" Then CPPropery.Value = "Yes
Next CPProper

' Set the table name
If UCase(Left(strLocation, 5)) = "PROC(" The
strLocation = Mid(strLocation, 6
strLocation = Left(Trim(strLocation), Len(Trim(strLocation)) - 1
End I
DBTable.Location = strLocatio
End I
Next intLoo

ChangeConnection_Exit
Exit Su

ChangeConnection_Err
If intTries = 0 The
'Can't remember that the error number i
If Err.Number = -2147189176 The
intTries = intTries +
Resume Try_Agai
End I
End I
'Report Erro
Resume ChangeConnection_Exi
Resum
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top