need help on this; I want to have the textbox4 to have the sum of columns based on their employee Id.
I have this code but kept getting error.

strsql = "SELECT emp_id, COUNT(acdcalls) FROM CMS WHERE emp_id= '" & TextBox1.Text & "'"
oledbcon.Open()
Dim cmd As New OleDbCommand(strsql, oledbcon)

Dim reader As OleDbDataReader = cmd.ExecuteReader
reader.Read()
TextBox4.Text = reader("acdcalls")


reader.Close()
oledbcon.Close()

please help I'm a newbie here.:sweat:

strsql = "SELECT sum(acdcalls) as acdcalls FROM CMS where emp_id= '" & TextBox1.Text & "'"
oledbcon.Open()
Dim cmd As New OleDbCommand(strsql, oledbcon)

Dim reader As OleDbDataReader = cmd.ExecuteReader
reader.Read()
TextBox4.Text = reader("acdcalls")


reader.Close()
oledbcon.Close()

COUNT function to count how much record in current column.
SUM function to added all value in current column.
AVG function to get average of all value in current column.
etc...
Well Great to solved your thread by your self.
Happy coding friend :)

commented: good explain +1

I am trying to get the Sum values of a Column and want to check if entered value in Textbox is valid.

Here is my code below

mystr = ("Provider=Microsoft.JET.OLEDB.4.0;" & _
"Data Source=K:\Amrut Diary\Amrut_Diary\ADDB.mdb")
con = New OleDb.OleDbConnection(mystr)
con.Open()

strsql = "SELECT SUM(Available_Stock) As Avstk FROM STOCKDB Where Material_Name= '" & TMtNm.Text & "'"
Dim cmd As New OleDbCommand(strsql, con)
Dim reader As OleDbDataReader = cmd.ExecuteReader
cmd.ExecuteReader()
If TQty.Text > reader("Avstk") Then
MsgBox("Quantity Overflow")
TQty.Text = ""
TQty.Focus()
End If

When I execute, I am Getting "No value given for one or more required parameters." Error

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.