Hi There,

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)

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
                If TQty.Text > reader("Avstk") Then
            MsgBox("Quantity Overflow")
            TQty.Text = ""
        End If

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

You are passing in a value from the TMtNm.Text textbox right? If that was empty you would get an error similar to that.
I may be jumping the gun here but you also aren't taking care of many error conditions either. What if the material entered can't be found or the user doens't enter an integer into the amount textbox?

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.