Database logon failed. crystal report 2008 in 3.5

I have created report in Crystal report 2008 on one PC which is working fine. When I change My PC i.e Copy rpt to another PC with different DB name but same schema, i not able to connect to that DB. Report shows msg as "Database logon failed."
For making work it proper I have written the following code to bind report.
Here I am passing Parameter as encrypted query string.
Query string contains RPT name, Parameter with values of Reports and FORMULAFIELD.
Kindly help me as soon as possible.
Thanks in advance for helping.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Request.QueryString("ID") Is Nothing Then
            Dim strEncryptedParameters, strDecryptedParameters As String
            strEncryptedParameters = Request.QueryString("ID").ToString()
            Dim objEncryptDecrypt As EncryptDecrypt = New EncryptDecrypt()
            strDecryptedParameters = objEncryptDecrypt.DecryptString(strEncryptedParameters.ToString().Replace(" ", "+"))
            If strDecryptedParameters <> "" And Not strDecryptedParameters.Contains("Invalid character") Then
                Dim strParams() As String
                Dim strParameter() As String
                Dim strParameterName, strParameterValue As String
                    strParams = strDecryptedParameters.Split("##")

                    For Each strParameterNameValuePair As String In strParams
                        If strParameterNameValuePair <> "" Then
                            strParameter = strParameterNameValuePair.Split("=")
                            If strParameter.Length = 2 Then
                                strParameterName = strParameter(0)
                                strParameterValue = strParameter(1)
                            End If

                        End If
                Catch ex As Exception
                    Response.Write("<script type='text/javascript'>window.close();</script>")
                End Try

            End If

        End If

    End Sub

    Private Sub BindReport(ByVal strDecryptedParameters As String)
            'Declaring variables
            Dim intCounter As Integer
            'Crystal Report's report document object
            Dim objReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            'object of table Log on info of Crystal report
            Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo
            'Parameter value object of crystal report
            ' parameters used for adding the value to parameter.
            Dim paraValue As New CrystalDecisions.Shared.ParameterDiscreteValue
            'Current parameter value object(collection) of crystal report parameters.
            Dim currValue As CrystalDecisions.Shared.ParameterValues
            Dim strNameValPair() As String
            Dim strTempNameValPair() As String
            Dim strProcAttrNameValPair() As String
            Dim strVal() As String
            Dim index As Integer
                strNameValPair = strDecryptedParameters.Split("$$")
                For i = 0 To strNameValPair.Length - 1
                    strTempNameValPair = strNameValPair(i).Split("##")
                    Select Case strTempNameValPair(0)
                        Case "FORMULAFIELD"
                            For Each strTemp As String In strTempNameValPair
                                If strTemp <> "" And InStr(strTemp, "=") > 0 Then
                                    Dim strParamterNameValue() As String = strTemp.Split("=")
                                    objReport.DataDefinition.FormulaFields(strParamterNameValue(0)).Text = "'" & strParamterNameValue(1) & "'"
                                End If

                        Case "REPORT"
                            Dim arrReportinfo As String = strTempNameValPair(1)
                            Dim arrTempReportinfo() As String
                            For Each strTemp As String In strTempNameValPair
                                If strTemp <> "" And InStr(strTemp, "=") > 0 Then
                                    arrTempReportinfo = strTemp.Split("=")
                                    '    'Load the report
                                    objReport.Load(HttpContext.Current.Server.MapPath("../RPT/" & arrTempReportinfo(1) & ".rpt"))
                                End If

                        Case "PARAMETERS"
                            strProcAttrNameValPair = strTempNameValPair(1).Split("##")
                            'Check if there are parameters or not in report.
                            intCounter = objReport.DataDefinition.ParameterFields.Count
                            'Assign all the Paramters here in a Loop
                            If intCounter > 0 And Trim(strDecryptedParameters) <> "" Then
                                For index = 1 To UBound(strTempNameValPair)
                                    If InStr(strTempNameValPair(index), "=") > 0 Then
                                        strVal = strTempNameValPair(index).Split("=")
                                        paraValue.Value = strVal(1)
                                        currValue = objReport.DataDefinition.ParameterFields("@" & strVal(0)).CurrentValues
                                        objReport.DataDefinition.ParameterFields("@" & strVal(0)).ApplyCurrentValues(currValue)
                                    End If
                            End If
                    End Select


                Dim dbInfo As New DatabaseInfo
                dbInfo = GetDatabaseInfo()
                'Set the connection information to ConInfo
                'object so that we can apply the
                'connection information on each table in the report
                ConInfo.ConnectionInfo.UserID = dbInfo.DbUserID
                ConInfo.ConnectionInfo.Password = dbInfo.DbPassword
                ConInfo.ConnectionInfo.ServerName = dbInfo.DatabaseServer
                ConInfo.ConnectionInfo.DatabaseName = dbInfo.DatabaseName
                For intCounter = 0 To objReport.Database.Tables.Count - 1

                Dim logonInfo As New TableLogOnInfos()
                crViewer.LogOnInfo = GetLogonInfos(logonInfo)
                'Re setting control
                crViewer.ReportSource = Nothing
                'Set the current report object to report.
                crViewer.ReportSource = objReport
                'Show the report

            Catch ex As Exception
                Dim str As String = ex.Message
            End Try
        Catch ex As Exception
            Dim str As String = ex.Message

        End Try
    End Sub

    Public Function GetDatabaseInfo() As DatabaseInfo
        Dim Dbinfo As New DatabaseInfo
        Dim strConnectionString As String = ""
        Dim arrInfo(), arrTempInfo() As String
        Dim strKey, strValue As String
        strConnectionString = ConfigurationManager.ConnectionStrings("Roshan").ToString
        arrInfo = strConnectionString.Split(";")
        For Each sectionEntry As String In arrInfo
            arrTempInfo = sectionEntry.Split("=")
            strKey = arrTempInfo(0).Replace(" ", "")
            strValue = arrTempInfo(1)
            Select Case strKey
                Case "InitialCatalog"
                    Dbinfo.DatabaseName = strValue
                Case "DataSource"
                    Dbinfo.DatabaseServer = strValue
                Case "UserID"
                    Dbinfo.DbUserID = strValue
                Case "Password"
                    Dbinfo.DbPassword = strValue
                Case "IntegratedSecurity"
                    Dbinfo.DbIntegratedSecurity = Convert.ToBoolean(strValue)
                Case "providerName"
                    Dbinfo.DbProviderName = strValue
            End Select
        GetDatabaseInfo = Dbinfo
        Return GetDatabaseInfo
    End Function

    Private Function GetLogonInfos(ByVal logonInfos As TableLogOnInfos) As TableLogOnInfos
        Dim dbInfo As New DatabaseInfo
        dbInfo = GetDatabaseInfo()
        ''This will add conn. info. to TableLogOnInfos collection
        Dim logonInfo As New TableLogOnInfo()
        logonInfo.ConnectionInfo.ServerName = dbInfo.DatabaseServer
        logonInfo.ConnectionInfo.DatabaseName = dbInfo.DatabaseName
        logonInfo.ConnectionInfo.UserID = dbInfo.DbUserID
        logonInfo.ConnectionInfo.Password = dbInfo.DbPassword
        logonInfo.ConnectionInfo.IntegratedSecurity = dbInfo.DbIntegratedSecurity
        GetLogonInfos = logonInfos
    End Function

Open in new window

Fahad PathanTeam LeaderAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kelvin McDanielSr. Developer/ConsultantCommented:
This will sound silly, but do you have permissions on that PC's database and schema?
Fahad PathanTeam LeaderAuthor Commented:
i am using admin rights for the same.
Also one more thing... when i created my rpt on first pc, its backend was MS SQL 2005 and when I trying to run it on another pc its backend is MS SQL 2008.
But when I save rpt on another PC then reports runs fine.
I cant do this for every rpt!!!
Do you have to change the database driver when you change databases?  If so I don't think there is a way to do that through code.

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Fahad PathanTeam LeaderAuthor Commented:
Thanks for reply..
But i didnt got what you are trying to say....
If you use the SET LOCATION ability in Crystal does it require a differnet driver for SQL 2008?


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fahad PathanTeam LeaderAuthor Commented:
ok.. so on another PC I have SQL 2008 and on my web hosting server having same version, and if I save that report on another PC again will it work in my web hosting server?
Fahad PathanTeam LeaderAuthor Commented:
whenever you create CR on any version of MS SQL Server, if change the version of MS SQL Server, do set the location of report again.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.