PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2010 [RESOLVED] How to Auto copy last record of column to text box and divide the value.-VBForums
Results 1 to 5 of 5

Thread: [RESOLVED] How to Auto copy last record of column to text box and divide the value.

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2018
    Posts
    90

    Resolved [RESOLVED] How to Auto copy last record of column to text box and divide the value.

    hi All,

    I want to make a program that will auto copy the last value of a column in sql server table to a text box and divide the value and show result to another text box.

    I want if i click load it will automatic compute show all value in text box.
    is that possible ? i'm using vb 2010
    thanks in advance.

    Name:  ddd.PNG
Views: 300
Size:  42.4 KB

    here is my current code to get the query .

    Code:
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            connection.Open()
            sqlCmd = connection.CreateCommand
            ' sqlCmd.CommandText = "SELECT * FROM Muscatel_MPCA_FCT1_LogData_T where SQLDateTime >= '2018-07-02T08:00:00 AM' AND SQLDateTime <= '2018-07-03T07:59:00 AM'"
    
            sqlCmd.CommandText = "WITH Src AS (SELECT station_no,CASE WHEN TestResult = 'ok' THEN 1 END AS ok,CASE WHEN TestResult = 'NG' " &
                "THEN 1 END AS NG,CASE WHEN TestResult = 'RR' THEN 1 END AS RR FROM test_table WHERE SQLDateTime >= '2018-07-02T08:00:00 AM'AND SQLDateTime <= '2018-07-03T07:59:00 AM'and Station_No in (1,2,3,4,5,6))SELECT station_no, COUNT(ok) AS TotalOK,COUNT(NG) AS TotalNG,COUNT(RR) AS TotalRR,COUNT(ok) + COUNT(NG) + COUNT(RR) AS Total FROM Src GROUP BY ROLLUP (Station_No)ORDER BY Station_No DESC"
            Dim dr As SqlDataReader = sqlCmd.ExecuteReader
            If dr.HasRows Then
                Dim dtRecords As New DataTable
                dtRecords.Load(dr)
                DataGridView1.DataSource = dtRecords
            End If
            dr.Close()
            connection.Close()
    
        End Sub
    Last edited by BONITO; Jul 10th, 2018 at 11:30 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width