Locked how to Progressbar in this codes?

  • Tuesday, May 15, 2012 1:18 PM
     
      Has Code

    Hi All

    I have use this codes in my project

    For Each dr As DataRow In DsReports.DataTable
    
                Dim Cmd As New SqlClient.SqlCommand("INSERT INTO Temp " & _
                                          "VALUES (@ID, @AccountDeatil,@Debit,@Credit)", Cn)
                Cmd.Parameters.AddWithValue("@ID", dr.Item(0))
                Cmd.Parameters.AddWithValue("@AccountDeatil ", dr.Item(1))
                Cmd.Parameters.AddWithValue("@Debit ", dr.Item(2))
                Cmd.Parameters.AddWithValue("@Credit ", dr.Item(3))
               Cmd.ExecuteNonQuery()
            Next
    

    Now How to use ProgressBar1 into Code

    thanks


    Name of Allah, Most Gracious, Most Merciful and He created the human

All Replies

  • Tuesday, May 15, 2012 4:01 PM
     
     

    How To use Progress bar

    I Want CountRecord


    Name of Allah, Most Gracious, Most Merciful and He created the human

  • Wednesday, May 16, 2012 5:11 AM
    Moderator
     
     

    Hi sh2013,

    Welcome to the MSDN forum.

    According to your description, it seems that you want to use process bar when you insert a record into database. I will suggest you don’t use it, because the process bar is used for the job which will cost lots of time. The time inserting a record is short and will be ignored by customer, So you don’t need to use it. Here is some information and sample about process bar: http://msdn.microsoft.com/en-us/library/system.windows.forms.progressbar.aspx

    The ProgressBar control is typically used when an application performs tasks such as copying files or printing documents. Users of an application might consider an application unresponsive if there is no visual cue. By using the ProgressBar in your application, you alert the user that the application is performing a lengthy task and that the application is still responding.

    Hope this helps.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us

  • Thursday, May 17, 2012 9:18 AM
     
     Answered

    Hi Sh2013,

    Try this code

    Dim cmd As New SqlCommand
            cmd.CommandText = "select EmpNo,EmpName FROM Emp"
            cmd.Connection = connection
            Dim da As New SqlDataAdapter(cmd)
            Dim ds As New DataSet
            da.Fill(ds)

            ProgressBar1.Minimum = 0
            ProgressBar1.Maximum = ds.Tables(0).Rows.Count
            ProgressBar1.Value = 0
            ProgressBar1.Step = 1
            For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
                DataGridView1.Rows.Add(ds.Tables(0).Rows(i)(0).ToString, ds.Tables(0).Rows(i)(0).ToString)
                ProgressBar1.PerformStep()
            Next