none
Database login - Crystal Report - VB.NET - Windows Forms RRS feed

  • Question

  •  
    Staff

        Good night, based on the code below am the following issues:

    1) The opening screen of the database login, password to verify the claims that must be done?
    2) And how should I do to refresh when the user presses, he update the report?

    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim frm As New Form2
            frm.Show()
        End Sub
    End Class

    Public Class Form2
        Private Sub crptempresas_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles crptempresas.Load
            Dim dbstrconexao As String = "User ID=system;Password=fernanda;Data Source=ORCL;"
            Dim dbcnnconexao As New OracleConnection
            Dim dbcmdconexao As New OracleCommand
            Dim dbdstconexao As New DataSet
            Dim telarpt As New relempresascrp
            dbcnnconexao.ConnectionString = dbstrconexao
            Try
                dbcnnconexao.Open()
            Catch ex As Exception
                MessageBox.Show(ex.Message, " Erro 1 ", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
            Try
                dbcmdconexao.Connection = dbcnnconexao
                With dbcmdconexao
                    .CommandText = "BUSCAPORCEP"
                    .CommandType = CommandType.StoredProcedure
                    .Parameters.Add("CEP_ID", OracleType.NVarChar, 8).Value = Form1.TextBox1.Text.ToString
                    .Parameters(0).Direction = ParameterDirection.Input
                    .Parameters.Add("EMPRESAS_C", OracleType.Cursor)
                    .Parameters(1).Direction = ParameterDirection.Output
                End With
                Try
                    Dim dbadpconexao As New OracleDataAdapter(dbcmdconexao)
                    dbadpconexao.Fill(dbdstconexao)
                    telarpt.SetDataSource(dbdstconexao.Tables(0))
                    crptempresas.ReportSource = telarpt
                Catch ex As Exception
                    MessageBox.Show(ex.Message, " Erro 2 ", MessageBoxButtons.OK, MessageBoxIcon.Error)
                End Try
            Catch ex As Exception
                Console.WriteLine(ex.Message)
            End Try
            dbcmdconexao.Dispose()
            dbcnnconexao.Close()
            dbcnnconexao.Dispose()
        End Sub
    End Class


    Oi Beleza, tem como me ajudar
    Thursday, December 4, 2008 2:40 AM

Answers

  • Hi Nei Bala,

    If you are using Crystal report viewer to view the report  their is no need to write the code, Refresh button is placed on the report viewer itself, you can find it below the titlebar for the report viewer.

    Else you can wite a code on a button click event also

    --------------------------
    Ali W.Qureshi
    • Marked as answer by Figo Fei Tuesday, December 9, 2008 3:21 AM
    Thursday, December 4, 2008 7:27 AM

All replies

  • Hi Nei Bala,

    If you are using Crystal report viewer to view the report  their is no need to write the code, Refresh button is placed on the report viewer itself, you can find it below the titlebar for the report viewer.

    Else you can wite a code on a button click event also

    --------------------------
    Ali W.Qureshi
    • Marked as answer by Figo Fei Tuesday, December 9, 2008 3:21 AM
    Thursday, December 4, 2008 7:27 AM
  • eassy and simple solution for all ....
    open field explorer---> database field --->Right Click -->current Data source --->reports connection----->report ----->property ----> set Property as---

    Data Source: .\Databasename.accdb

    and code on viewer form load as

    Dim cryRpt As New ReportDocument

        Dim Report1 As New rptItemWise

        Dim strServerName As String
        strServerName = Application.StartupPath
    rptItemWise.SetDatabaseLogon("admin", "", strServerName, "dastabasename.accdb", True)



        cryRpt.Load(Application.StartupPath + "\rptItemWise.rpt")

    also change the report connection same as data source i think that code work for you ..
    Tuesday, December 9, 2014 7:58 AM