Dear All,

I have a problem i have made setup of my project when i install it and run the program it asks for the complete path of database like this "C:\Paymentsystem\PaymentSystem\bin\Debug"

is there any way i want to change the path i mean i want to place database in d drive please help.

Yes. You do that in the connection string.
Assuming that you're using an Access database, then the connection string might look something like this.
Notice the Data Source path.

Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\mydatabase.mdb;User Id=admin;Password=;")

Actually i am using this connecting string

Dim cnString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Application.StartupPath & "\Payment.mdb;"

I see.
Well, if you want to load a database from another drive you will have to change that.
In other words, replace Application.StartupPath with a hardcoded path: D:\<path_to_database>\Payment.mdb

Ok now the problem is with report when i run it throws exception load report error i am using this code:

If TextBox1.Text = "" Then
            MessageBox.Show("Please enter PlotNo!", "ALI ENTERPRISES", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Exit Sub
        End If
        TextBox1.Visible = False
        Button1.Visible = False
        Dim cryRpt As New ReportDocument
        cryRpt.Load("D:\PaymentSystem\PaymentSystem\Hir.rpt")
        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldDefinition As ParameterFieldDefinition
        Dim crParameterValues As New ParameterValues
        Dim crParameterDiscreteValue As New ParameterDiscreteValue

        crParameterDiscreteValue.Value = TextBox1.Text
        'crParameterDiscreteValue.Value = TextBox2.Text
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields()
        crParameterFieldDefinition = _
        crParameterFieldDefinitions.Item("PlotNo")
        crParameterValues = crParameterFieldDefinition.CurrentValues

        crParameterValues.Clear()
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

        CrystalReportViewer1.ReportSource = cryRpt
        CrystalReportViewer1.Refresh()
    End Sub

What should i do to resolve this problem please help me.

Assuming that the error occurs on line 8, then the most likely cause is the path.
Is it correct?

yes error comes on line no 8 ok can i use this code here "Application.StartupPath"

Application.StartupPath points to the folder where your appliction is executed from.

For example, if you install your application to "C:\SomeKindOfApp\myapp.exe", then Application.StartupPath will point to "C:\SomeKindOfApp".

So, if the report you wish to load is on another disk, then Application.StartupPath won't work.
However, if the report file is located in the same folder as your executable, then Yes, Application.StartupPath will work perfectly.

Yes reports are in same folder then how to use application.startuppath

On line 8, do this: cryRpt.Load(Application.StartupPath & "\Hir.rpt")

its not woking same eorror occured again.

What are the properties for the report file?

Check "Build Action", if it's set to Embedded Resource, then change that to None.
Check "Copy to Output Directory", if it's set to Do not copy, then change that to Copy always.

You need to make sure that the report file resides in the directory you are trying to load it from.

i have try this but its giving me same error what should i do now?

Thanks it working

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.