Skip to Content
0
Former Member
Nov 02, 2013 at 09:41 AM

Failed to retrieve data from database Vendor Code 2812

1681 Views

Sir, i have Installed the Crystal Reports for Visual Studio.Net 2010 (CRforVS_13_0_4) and created many reports, those reports are working fine with the following code as long as my PC is same where i have created the report. (Reports are created with Stored Procedures in backend)....But when i moved to another PC all reports are giving error.

"Failed to retrieve data from database"

Details: [Database Vendor Code 2812]

Error in File ItemTypesReport (ItemTypes Report is the Crystal Report)

Following is my code.

Public Sub Preview_ReportWithParameters(ByVal CrystalReportName As String)

Try

If SqlConn.State = 1 Then SqlConn.Close()

Dim frmReport As New ReportDisplay

Dim crDocument As New ReportDocument

Dim reportPath As String = My.Application.Info.DirectoryPath + "\" + CrystalReportName + ".rpt"

crDocument.Load(reportPath)

crDocument.SetParameterValue("@UserID", Convert.ToInt64(mUserID))

crDocument.SetParameterValue("@ActionCode", "1")

crDocument.SetParameterValue("@SearchText", "")

Dim crConnectionInfo As ConnectionInfo = New ConnectionInfo()

crConnectionInfo.ServerName = mSQLServername

crConnectionInfo.DatabaseName = mSQLDatabaseName

crConnectionInfo.UserID = mSQLUser

crConnectionInfo.Password = mSQLPassword

Dim crTables As Tables = crDocument.Database.Tables

For Each crTable As CrystalDecisions.CrystalReports.Engine.Table In crTables

Dim crTableLogonInfo As TableLogOnInfo = crTable.LogOnInfo

crTableLogonInfo.ConnectionInfo = crConnectionInfo

crTable.ApplyLogOnInfo(crTableLogonInfo)

Next

frmReport.crViewer.ReportSource = Nothing

frmReport.crViewer.DataBindings.Clear()

frmReport.crViewer.ReportSource = crDocument

frmReport.Show()

frmReport.Refresh()

SqlConn.Close()

'crDocument.Dispose()

Catch ex As Exception

'If Err.Number = 5 Or Err.Number = 91 Then

' MsgBox("Sorry, no record is selected to preview, you must select a record.", MsgBoxStyle.Information, "No record selected")

'Else

MsgBox("Error No: " & Err.Number & vbNewLine & ex.ToString, MsgBoxStyle.Information, "No record selected")

'End If

End Try

End Sub

To Call the above Procedure

Preview_ReportWithParameters("ItemTypesReport")

Attachments

CR_Error.png (38.1 kB)