Ask Experts Questions for FREE Help !
Ask
    omar_tariq's Avatar
    omar_tariq Posts: 2, Reputation: 1
    New Member
     
    #1

    Oct 19, 2011, 06:36 PM
    Programming vb question
    Hello and good day to all...

    I created a database contains "Down Time" table inside this table there is 'employee number' , 'no material PC' and other columns and now I am programming in Visual Basic 2010 and I want to retrieve all the sum of all values that entered into 'no material PC' column in one text box for all employees who entered a record for this column.

    Thanks a lot I really appreciate your help


    This is my code

    //




    Private Sub LoudData()
    Dim myConnection As SqlConnection
    Dim cmd As SqlClient.SqlCommand
    Dim DR As SqlClient.SqlDataReader
    Dim strQuery As String



    'Loss Time No Material PC

    myConnection = New SqlConnection("server=SHHW0037\METSDATABASE;uid=ME TSDATABASE;pwd=METSDB;database=METS")



    strQuery = ("If EXISTS (SELECT * FROM DownTime WHERE Process ='" TextBox1.Text "' AND Date ='" DateTimePicker1.Value.ToString("MM/dd/yyyy ") "') SELECT NoMaterialPC FROM DownTime WHERE Process ='" TextBox1.Text "' AND Date ='" DateTimePicker1.Value.ToString("MM/dd/yyyy") "'")



    Try

    myConnection.Open()
    cmd = New SqlClient.SqlCommand(strQuery, myConnection)
    DR = cmd.ExecuteReader()
    While DR.Read()

    TextBox3.Text = CStr(DR.GetInt32(0))

    End While
    DR.Close()
    myConnection.Close()
    Catch ex As Exception
    MessageBox.Show(ex.Message)
    End Try

    //
    omar_tariq's Avatar
    omar_tariq Posts: 2, Reputation: 1
    New Member
     
    #2

    Oct 20, 2011, 11:36 PM
    Thanks all problem solved I just add sum after SELECT and put a Bracket around the column name

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

C programming [ 2 Answers ]

I'll be extremely thankful if u could provide me with a c program that convert a given nfa to dfa

Programming Question. [ 3 Answers ]

Hi, I'm stumped with this.. Can you please help? How would I design nested structures that perform: If amount1 is greater than 10 and amount2 is less than 100, display the greater of amount1 and amount2

I'm trying to get into programming. [ 3 Answers ]

I have no clue were to start and I don't have the money for a collige but maybe someone can help a site or anything... well thank you for you're time Scythe.

Qt programming [ 1 Answers ]

Hi, My name is anshahmed.I am doing final year B.TECH.Now I am doing a project and I want to use qt programming .Whie I was compiling the qt programm the compiler giving errors in header file(qpplicaton.h) .how can I compile the qt programm.


View more questions Search