cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal XI problem with .AddADOCommand under MS vista

Former Member
0 Kudos

This works fine under Windows XP but fails under Windows Vista. We have upgraded to the latest fix pack, 5.4, but this has not fixed our problem.

The followong code crashes when trying to execute the .AddADOCommand line:

Dim crxReport As New CRAXDRT.Report

Dim cmd As Command

Set cmd = New Command

Set crxReport = crxApplication.NewReport

cmd.ActiveConnection = conn

cmd.CommandText = sSQLGrid

cmd.CommandType = adCmdUnknown

crxReport.Database.AddADOCommand conn, cmd

The error comes back with -2147189176 "Logon failed."

Any help would be greatly appreciated.

Thanks

Boris Cousins

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Boris,

Which ADO control did you add to your VB6 project?

This is likely a problem with MS OLDB drivers not being installed on the Vista Machine.

Use Modules or Process explorer to see what is missing.

May be a permission issue also. Microsoft also has an OLEDB test tool called RowSetViewer that you can use to test your OLD DB connections on the Vista PC.

Thank you

Don

Former Member
0 Kudos

Don,

Thanks for your reply. We are using the Crystal Active X report Viewer Library 11.5 (crviewer.dll).

I tried using modules and RowSetViewer, the OLEDB connections on the vista machine look fine and are used elsewhere in our application with no problems.

Thanks,

Boris.

0 Kudos

Hi Boris,

Try this:

' *************************************************************

' Purpose: Demonstrate new methods of adding ADO connections to reports

'

' There are two new methods that provide a convenient

' way to add ADO data sources to a report:

' 1.) AddADOCommand takes as parameters an active ADO connection

' and an ADO command object. In this example, a new connection

' is created to a database, and the resulting recordset is assigned

' at runtime to the report

' 2.) AddOLEDBSource takes as parameters the name of an active

' ADO connection and the name of a table that can be accessed

' through that connection. In this example, the connection set

' up through the VB Data Environment is used as a data source.

'

' Both methods can be used with either the VB Data Environment

' or another data source created at runtime.

' Notice in the Crystal Report design environment that there is

' no data source attached to the report at design time.

'

Option Explicit

Dim m_Report As New CrystalReport1

' The ADO connection to the local database.

Dim cnn1 As ADODB.Connection

Dim datcmd1 As ADODB.Command

' *************************************************************

' Demonstrate the use of AddADOCommand by opening an ADO data command,

' adding the data source to the report, and then adding a field

' to the report that uses that data source.

'

Private Sub cmdADO_Click()

Dim fld As FieldObject

Dim strCnn As String

' Open the data connection

Set cnn1 = New ADODB.Connection

strCnn = "Provider=MSDASQL;Persist Security Info=False;Data Source=Xtreme Sample Database 10;Mode=Read"

cnn1.Open strCnn

' Create a new instance of an ADO command object

Set datcmd1 = New ADODB.Command

Set datcmd1.ActiveConnection = cnn1

datcmd1.CommandText = "Customer"

datcmd1.CommandType = adCmdTable

' Add the datasource to the report

m_Report.Database.AddADOCommand cnn1, datcmd1

' Add a new field object to the report and set the field object to use

' the new data source.

Set fld = m_Report.Section3.AddFieldObject("{ado.Customer Name}", 0, 0)

LoadReport

End Sub

' *************************************************************

' Demonstrate the use of AddOLEDBSource by opening an ADO data source,

' adding the data source to the report, and then adding a field

' to the report that uses that data source. In this example, the

' OLEDB source in the VB Data Environment is used

'

Private Sub cmdOLEDB_Click()

Dim fld As FieldObject

' Add the datasource to the report

m_Report.Database.AddOLEDBSource DataEnvironment1.Connection1, "Customer"

' Add a new field object to the report and set the field object to use

' the new data source.

Set fld = m_Report.Section3.AddFieldObject("{Customer.Customer Name}", 0, 0)

LoadReport

End Sub

' *************************************************************

' Load the Report in the viewer

'

Private Sub LoadReport()

Screen.MousePointer = vbHourglass

CRViewer1.ReportSource = m_Report

CRViewer1.ViewReport

Screen.MousePointer = vbDefault

cmdOLEDB.Enabled = False

cmdADO.Enabled = False

End Sub

' *************************************************************

Private Sub cmdAbout_Click()

frmAbout.Show vbModal

End Sub

' *************************************************************

Private Sub cmdExit_Click()

Unload Me

End Sub

Thank you

Don

Former Member
0 Kudos

Don,

I tried that and I get an error of "Method 'Database' of object 'IReport' failed"...

just to clarify the line in your code:

Dim m_Report As New CrystalReport1

I had to change to:

Dim m_Report As New CRAXDRT.Report

Regards,

Boris

0 Kudos

Hi Boris,

This works for me so it must be something missing or permissions to resources/dependencies on Vista. Run Modules and compare runtime between XP and Vista. Try turning DEP off completely also, could be Vista is blocking access. Search forums for info on disabling DEP and then re-install your deployment package. I've see DEP at times not return any errors when installing CR runtime but when looking at the list some dll's did not get updated.

Thanks

Don

Former Member
0 Kudos

Thanks Don, you put me in the right direction.

After further exploration, we had to add "Persist Security Info=True" to our connection string of our ado connection; then when this connection is passed to .AddADOCommand, it works!

Thanks once again.

Boris.

Answers (0)