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.
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




Reply With Quote
