how to publish a VB.Net project with crystal report desu?

时间:2017-04-10 00:49:18

标签: vb.net visual-studio-2012 crystal-reports

Hope I'm not crossing any lines or breaking any rules. I need help in publishing my project (vb.net2012 with crystal report). I need A step by step Guide. Please Help, I've done everything I know, and made a deep search but none was effective so far.

Thanks desu...

EDIT:

One fix tried was that I've configured the "Copy to Output Directory" option to "Always Copy" but it didn't work desu.

Here are the codes that I used desu:

Imports System.Data.OleDb 
Imports CrystalDecisions.CrystalReports.Engine 
Imports CrystalDecisions.Shared

Public Class crpReport

Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Doj2\bpp-doj\dbbppcounter.accdb;Persist Security Info=True;Jet OLEDBatabase Password=*****"

Dim MyConn As OleDbConnection
Dim da As New OleDbDataAdapter
Dim ds As DataSet
Dim tables As DataTableCollection
Dim source1 As New BindingSource
Public acscmd As New OleDbCommand
Public acsconn As New OleDbConnection
Public acsda As New OleDbDataAdapter
Public acsds As New DataSet
Public strsql As String
Public strreprotname As String
Dim cryRpt As New ReportDocument

'cryRpt.Load("C:\Users\BPPADMIN\Desktop\Cares2.50\Cares2.50\carpetas.rpt"

Private Sub form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
    Dim cryRpt As New ReportDocument

    cryRpt.Load(Application.StartupPath + "\\carpetas.rpt"

    CrystalReportViewer1.ReportSource = cryRpt
    CrystalReportViewer1.Refresh()

    If lbVariable2.Text = "Name" Then

        Call Name_Search()
    ElseIf lbVariable2.Text = "Date" Then

        Call DateSearch()

    ElseIf lbVariable2.Text = "PrintAll" Then

        Call PrintAll()

    End If




End Sub

Private Sub Name_Search()



    Dim cryRpt As New ReportDocument
    Dim crConnectionInfo As New ConnectionInfo()
    Dim Name As String
    Dim crtableLogoninfos As New TableLogOnInfos
    Dim crtableLogoninfo As New TableLogOnInfo


    Name = ""


    If lbVariable.Text = "LastName" Then

        acsconn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Doj2\bpp-doj\dbbppcounter.accdb;Persist Security Info=True;Jet OLEDBatabase Password=*****"
        acsconn.Open()

        strsql = "select * from RHH_CARES where Last_Name='" & Report.tbText.Text & "' and active = '" & 1 & "'"
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsda.SelectCommand = acscmd
        acsda.Fill(acsds)

        cryRpt.Load(Application.StartupPath + "\\carpetas.rpt"
        cryRpt.SetDataSource(acsds.Tables(0))
        CrystalReportViewer1.ReportSource = cryRpt




    ElseIf lbVariable.Text = "FirstName" Then

        acsconn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Doj2\bpp-doj\dbbppcounter.accdb;Persist Security Info=True;Jet OLEDBatabase Password=*****"
        acsconn.Open()

        strsql = "select * from RHH_CARES where First_Name='" & Report.tbText.Text & "' and Active = '" & 1 & "'"
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsda.SelectCommand = acscmd
        acsda.Fill(acsds)

        cryRpt.Load(Application.StartupPath + "\\carpetas.rpt"
        cryRpt.SetDataSource(acsds.Tables(0))
        CrystalReportViewer1.ReportSource = cryRpt

    ElseIf lbVariable.Text = "MiddleName" Then

        acsconn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Doj2\bpp-doj\dbbppcounter.accdb;Persist Security Info=True;Jet OLEDBatabase Password=*****"
        acsconn.Open()

        strsql = "select * from RHH_CARES where Middle_Name='" & Report.tbText.Text & "' and Active = '" & 1 & "'"
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsda.SelectCommand = acscmd
        acsda.Fill(acsds)

        cryRpt.Load(Application.StartupPath + "\\carpetas.rpt"
        cryRpt.SetDataSource(acsds.Tables(0))
        CrystalReportViewer1.ReportSource = cryRpt

    ElseIf lbVariable.Text = "NameExt" Then

        acsconn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Doj2\bpp-doj\dbbppcounter.accdb;Persist Security Info=True;Jet OLEDBatabase Password=*****"
        acsconn.Open()

        strsql = "select * from RHH_CARES where Name_Extension='" & Report.tbText.Text & "' and Active = '" & 1 & "'"
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsda.SelectCommand = acscmd
        acsda.Fill(acsds)

        cryRpt.Load(Application.StartupPath + "\\carpetas.rpt"
        cryRpt.SetDataSource(acsds.Tables(0))
        CrystalReportViewer1.ReportSource = cryRpt

    ElseIf lbVariable.Text = "Gender" Then

        acsconn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Doj2\bpp-doj\dbbppcounter.accdb;Persist Security Info=True;Jet OLEDBatabase Password=*****"
        acsconn.Open()

        strsql = "select * from RHH_CARES where Gender='" & Report.tbText.Text & "' and Active = '" & 1 & "'"
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsda.SelectCommand = acscmd
        acsda.Fill(acsds)

        cryRpt.Load(Application.StartupPath + "\\carpetas.rpt"
        cryRpt.SetDataSource(acsds.Tables(0))
        CrystalReportViewer1.ReportSource = cryRpt

    ElseIf lbVariable.Text = "Username" Then

        acsconn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Doj2\bpp-doj\dbbppcounter.accdb;Persist Security Info=True;Jet OLEDBatabase Password=*****"
        acsconn.Open()

        strsql = "select * from RHH_CARES where Username='" & Report.tbText.Text & "' and Active = '" & 1 & "'"
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsda.SelectCommand = acscmd
        acsda.Fill(acsds)

        cryRpt.Load(Application.StartupPath + "\\carpetas.rpt"
        cryRpt.SetDataSource(acsds.Tables(0))
        CrystalReportViewer1.ReportSource = cryRpt

    ElseIf lbVariable.Text = "PrisonNumber" Then

        acsconn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Doj2\bpp-doj\dbbppcounter.accdb;Persist Security Info=True;Jet OLEDBatabase Password=*****"
        acsconn.Open()

        strsql = "select * from RHH_CARES where Prison_Number='" & Report.tbText.Text & "' and Active = '" & 1 & "'"
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsda.SelectCommand = acscmd
        acsda.Fill(acsds)

        cryRpt.Load(Application.StartupPath + "\\carpetas.rpt"
        cryRpt.SetDataSource(acsds.Tables(0))
        CrystalReportViewer1.ReportSource = cryRpt

    End If


End Sub

Private Sub DateSearch()

    If lbVariable.Text = "DateRec" Then

        Call Received()

    ElseIf lbVariable.Text = "DateEnd" Then

        Call Encoded()

    End If




End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    Me.Refresh()
End Sub

Private Sub PrintAll()

    acsconn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Doj2\bpp-doj\dbbppcounter.accdb;Persist Security Info=True;Jet OLEDBatabase Password=*****"
    acsconn.Open()

    strsql = "select * from RHH_CARES where Active= """ & 1 & """"
    acscmd.CommandText = strsql
    acscmd.Connection = acsconn
    acsda.SelectCommand = acscmd
    acsda.Fill(acsds)

    cryRpt.Load(Application.StartupPath + "\\carpetas.rpt"
    cryRpt.SetDataSource(acsds.Tables(0))
    CrystalReportViewer1.ReportSource = cryRpt



End Sub

Private Sub Received()

    Dim dFrom As String
    Dim dTo As String

    dFrom = Report.DateFrom.Value.ToString("MM/dd/yyyy"
    dTo = Report.DateTo.Value.ToString("MM/dd/yyyy"

    If Report.DateFrom.Value = Report.DateTo.Value Then

        acsconn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Doj2\bpp-doj\dbbppcounter.accdb;Persist Security Info=True;Jet OLEDBatabase Password=*****"
        acsconn.Open()

        strsql = "select * from RHH_CARES where Date_Received like # " & dFrom & "# and Active = '" & 1 & "'"
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsda.SelectCommand = acscmd
        acsda.Fill(acsds)

        cryRpt.Load(Application.StartupPath + "\\carpetas.rpt"
        cryRpt.SetDataSource(acsds.Tables(0))
        CrystalReportViewer1.ReportSource = cryRpt


    Else



        acsconn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Doj2\bpp-doj\dbbppcounter.accdb;Persist Security Info=True;Jet OLEDBatabase Password=*****"
        acsconn.Open()

        strsql = "select * from RHH_CARES where Date_Received>=# " & dFrom & "# and Date_Received <= #" & dTo & "# and Active = '" & 1 & "'"
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsda.SelectCommand = acscmd
        acsda.Fill(acsds)

        cryRpt.Load(Application.StartupPath + "\\carpetas.rpt"
        cryRpt.SetDataSource(acsds.Tables(0))
        CrystalReportViewer1.ReportSource = cryRpt
    End If


End Sub

Private Sub Encoded()

    Dim dFrom As String
    Dim dTo As String

    dFrom = Report.DateFrom.Value.ToString("MM/dd/yyyy"
    dTo = Report.DateTo.Value.ToString("MM/dd/yyyy"

    If Report.DateFrom.Value = Report.DateTo.Value Then

        acsconn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Doj2\bpp-doj\dbbppcounter.accdb;Persist Security Info=True;Jet OLEDBatabase Password=*****"
        acsconn.Open()

        strsql = "select * from RHH_CARES where Date_Encoded like # " & dFrom & "# and Active = '" & 1 & "'"
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsda.SelectCommand = acscmd
        acsda.Fill(acsds)

        cryRpt.Load(Application.StartupPath + "\\carpetas.rpt"
        cryRpt.SetDataSource(acsds.Tables(0))
        CrystalReportViewer1.ReportSource = cryRpt


    Else



        acsconn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Doj2\bpp-doj\dbbppcounter.accdb;Persist Security Info=True;Jet OLEDBatabase Password=*****"
        acsconn.Open()

        strsql = "select * from RHH_CARES where Date_Encoded>=# " & dFrom & "# and Date_Encoded <= #" & dTo & "# and Active = '" & 1 & "'"
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsda.SelectCommand = acscmd
        acsda.Fill(acsds)

        cryRpt.Load(Application.StartupPath + "\\carpetas.rpt"
        cryRpt.SetDataSource(acsds.Tables(0))
        CrystalReportViewer1.ReportSource = cryRpt
    End If

End

Sub
End Class

1 个答案:

答案 0 :(得分:0)

有一点可以肯定:

我只使用vb.net。

1. In your solution explorer
2. Right click project name
3. Clean then rebuild your project.
4. right Click your project
5. Goto project Directory.
6. bin Folder => copy all the files in there.
7. Paste to the PC you want to run.

部署:

1. Make sure VB.net run time installed.
2. Crystal report 32bit run time installed.
3. Make on your project before rebuild your Crystal Report properties has been 
Copy if Newer or Copy Always.

决赛是:

Check your crystal report if it is Exists in bin folder.
Run Exe file 
祝你好运。