0

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

Edited by Narue: Added code tags

2
Contributors
1
Reply
6
Views
6 Years
Discussion Span
Last Post by hericles
0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.