Ok. Count() is a SQL Aggregate function, it will count the number or rows for the specified column:
"SELECT Count(ATTDivision.DivisionCode) " & _
"FROM ATTDivision INNER JOIN " & _
"ATTEmployee ON ATTDivision.DivisionCode = ATTEmployee.DivisionCode " & _
"WHERE (ATTDivision.DivisionCode = '" & DivisionCode2.Text & " ') ")
So if the count statement here returns 0 it means that your query is returning 0 records.
Next you call the scalar value
Dim recordbedeleted As Boolean = (Convert.ToInt32(cmd.ExecuteScalar) = 0) Now I *assume* you are wanting to delete records from the table if there are no rows returned by your first query so if the scalar returns 0 recordbedeleted will become true otherwise false.
My suggestion is that if you are not getting the results you are expecting first test your SQL to verify what you *think* is coming back is actually the data that is coming back.
hth.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========