Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error -2147417848 with CR9 and VB6

Status
Not open for further replies.

MeGGaN

Programmer
Feb 4, 2003
45
0
0
MX
Hi!

Please Help! I'm using the RDC component on VB6, when I launch my report the first time it runs ok, when I call it a second time I get this error -2147417848.

Here is my simplyfied code:

Option Explicit

Dim pedidos As New CrystalReport1
Dim lConnCtrlPed As ADODB.Connection
...

Private Sub Form_Load()

Dim fCmdPedidos As ADODB.Command
Dim fRstPedidos As ADODB.Recordset
Dim ConnectionInfo As CRAXDRT.ConnectionProperties

Set fCmdPedidos = New ADODB.Command
Set fRstPedidos = New ADODB.Recordset
Set fCmdPedidos.ActiveConnection = fConn

Set ConnectionInfo = pedidos.Database.Tables(1).ConnectionProperties
'Set the OLE DB Provider
ConnectionInfo.Item("Provider") = "SQLOLEDB"
'Set the physical server name
ConnectionInfo.Item("Data Source") = "DIAGW2K2"
'Set the database name
ConnectionInfo.Item("Initial Catalog") = "MSPRUEBA"
'Set the integrated security
ConnectionInfo.Item("Integrated Security") = True
'Set the user name
ConnectionInfo.Item("User ID") = "sa"
'Set the password
ConnectionInfo.Item("Password") = "pass"
'Set the fully qualified table name if different from the original data source
pedidos.Database.Tables(1).Location = "MSPRUEBA.dbo.X_CTRLPED_REPORTE"

... Open recordset

pedidos.DiscardSavedData
pedidos.Database.SetDataSource fRstPedidos
CRViewer91.ReportSource = pedidos
CRViewer91.ViewReport

Do While CRViewer91.IsBusy
DoEvents
Loop

... close recordset

Set fRstPedidos = Nothing
Set ConnectionInfo = Nothing

end sub

I get the error when I run again the report and try to execute this line:

'Set the OLE DB Provider
ConnectionInfo.Item("Provider") = "SQLOLEDB"

Any help or ideas would be very appreciated.

Magda

________________
Magda Banuet
 
We have the same problem working with VB6 and ADO (ORACLE and mdb). The first run Ok, but the second execution of crystal.action = 1 fails.
Are you find solutions?

Thanks.
 
I found this by searching on your error number on the Business Objects Crystal support site.

The information in the article refers to:
Report Designer Component 6


Applies to:

Reported version and higher
Runtime Error -2147417848 (80010108)
Method 'ViewReport' of object 'lCrystalReportViewer' failed



Synopsis

When a report is previewed a second time through the Report Viewer in a Microsoft Visual Basic application using the Report Designer Component, you may receive the following error.

Runtime Error -2147417848 (80010108)
Method 'ViewReport' of object 'lCrystalReportViewer' failed


Solution

The report object needs to be destroyed after previewing the report. To destroy the Report object type the following code in the unload event of the form containing the Report Viewer.

Sample Code:

Private Sub Form_Unload(Cancel As Integer)
'When the fom unloads the Report object is destroyed.
Set Report = Nothing
End Sub



 
When I had this problem, I found out that I got the error when I tried to set the connection password a second time.

So, with my previous code posted, I did this:

If (pedidos.Database.Tables(1).TestConnectivity) Then
'ok
Else
Set ConnectionInfo = pedidos.Database.Tables(1).ConnectionProperties

'Set the OLE DB Provider
ConnectionInfo.Item("Provider") = "SQLOLEDB"
'Set the physical server name
ConnectionInfo.Item("Data Source") = "DIAGW2K2"
'Set the database name
ConnectionInfo.Item("Initial Catalog") = "MSPRUEBA"
'Set the integrated security
ConnectionInfo.Item("Integrated Security") = True
'Set the user name
ConnectionInfo.Item("User ID") = "sa"
'Set the password
ConnectionInfo.Item("Password") = "3c16465b"
'Set the fully qualified table name if different from the original data source
pedidos.Database.Tables(1).Location = "MSPRUEBA.dbo.X_CTRLPED_REPORTE"
End If

________________
Magda Banuet
 
Your code kinda messy a bit here is what I have CR9 VB6 and SQL2000. I already enter the provider, the database etc at the design time when I look for a table (well I create a view in my SQL2000). All it required is a password from me. Another the way is using this line of code
if TestConnectivity then
'do nothing
Else 'connect it
Report.Database.LogOnServer "SQLOLEDB", "Server", "DatabaseTable", "UserID", "Password"
end if


'my actual code from Form1 when create CR9 using ActiveX
Dim Report As New CrystalReport
Private Sub Form_Load()
'passing password
Report.Database.Tables.Item(1).ConnectionProperties.Item ("password") = "password"
CRViewer91.ReportSource = Report
CRViewer91.EnableRefreshButton = True

CRViewer91.ViewReport
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set Report = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top