choosechrist 0 Newbie Poster

I had started a similar thread earlier, but i did not get any explanations. I hope i am not crossing any line by repeating.

My problem is this. every form in my application accesses the database through a connection string within the startup(Login) form. the login inturn gets the user parameters from an xml file.

Public Sub ReadfromXML()
        Dim I As Integer
        Dim ServerName As String
        Dim DatabaseName As String
        Dim UID As String
        Dim PWD As String



        For I = 0 To 2
            Dim doc As XmlDocument = New XmlDocument()
            doc.Load("data.xml")

            Dim root As XmlElement = doc.DocumentElement

            ServerName = root.Attributes.Item(0).Value
            DatabaseName = root.Attributes.Item(1).Value
            UID = root.Attributes.Item(2).Value
            PWD = root.Attributes.Item(3).Value


            cnString = "server=" & ServerName & ";database=" & DatabaseName & ";User ID=" & UID & ";Password=" & PWD & ""
            

            CN = New SqlConnection

            Try
                With (CN)
                    If .State = ConnectionState.Open Then .Close()

                    .ConnectionString = cnString
                    .Open()
                    Exit For
                End With
            Catch ex As Exception
                If Err.Number = 5 Then
                    MsgBox("Cannot connect to server. Make sure that the server is running. " & vbCrLf & vbCrLf & "Otherwise please check for the configuration.", MsgBoxStyle.Exclamation)

                    'Dim DBPath As New frmDBPath

                    'DBPath.ShowDialog()
                End If
            Finally
                CN.Close()
            End Try
        Next (I)
    End Sub

now i am using crystal reports and i want the rpt files to access this connection either through the xml file or through the login form.right now what i am doing is, i created a normal form, inserted a crystal report viewer and within that form i put the code

cmd.Connection = thisConnection
        cmd.CommandType = CommandType.Text
        cmd.CommandText = "Select * from ATA_Pending"
        da.SelectCommand = cmd
        da.Fill(ds, "test")
        Dim strpath As String
        Dim strpath1 As String
        strpath = Application.StartupPath
        strpath1 = strpath.Remove(strpath.Length - 9, 9) + "ATAP.rpt"

        Dim cr As New ReportDocument
        cr.Load(strpath1)

    

        cr.SetDataSource(ds.Tables("test"))
        Me.crv1.ReportSource = cr

the rpt file i manually take database expert and create a connection "sql native client" . this works on a normal basis. but if i run it anywhere else(the published copy), the reports wont open.