garyinmiami2003
asked on
Retrieving a Max value from a table and storing in VB.net
My SQL statement looks like this
select max(SEQ_NO) AS expr1 where fld1 = 'strFld1'. According to the data this should return a number from 01 to 99, or null. I can execute the query separate from the program and it works. I need to know how to return the single value to process it. I am used to returning the values to a dataset and placing in a grid. I have 2 problems: It is reurning a 0 or null that produces an error when I try to return it t to a dataset. 2nd. How may I best refer to just one value returned from the query?
select max(SEQ_NO) AS expr1 where fld1 = 'strFld1'. According to the data this should return a number from 01 to 99, or null. I can execute the query separate from the program and it works. I need to know how to return the single value to process it. I am used to returning the values to a dataset and placing in a grid. I have 2 problems: It is reurning a 0 or null that produces an error when I try to return it t to a dataset. 2nd. How may I best refer to just one value returned from the query?
Can you post a section of code showing how you are attempting to get the results?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi garyinmiami2003;
Your SQL select statement needs a FROM clause to identify the table
select max(SEQ_NO) AS expr1 FROM TableName where fld1 = 'strFld1'
Fernando
Your SQL select statement needs a FROM clause to identify the table
select max(SEQ_NO) AS expr1 FROM TableName where fld1 = 'strFld1'
Fernando
ASKER
Dim money As Decimal = CDec(cmd.ExecuteScalar())
Was the statement I needed. Fernando, Thanks again for the high quality assistance
Was the statement I needed. Fernando, Thanks again for the high quality assistance
Not a problem, glad I was able to help. ;=)