I am trying to get a count of the number of rows in a MS SQL database through a script query. I have a Popup Calendar object and when the user selects the date, it will check to see if that week is in the database (count > 0), if it isn’t then a new record will be created. The query I have works in the database query browser, but returns an error when I try to run it. There will be a variable in place for the date to select once the code is completed. The script is in the propertyChange of the Popup Calendar object.
[code]if event.propertyName == “date”:
dayOfWeek = system.db.dateFormat(event.newValue, “E”)
weekStart = system.db.dateFormat(event.newValue, “YYYY-MM-DD”)
# Message If Sunday Not Selected
if dayOfWeek <> "Sun":
system.gui.messageBox("Please Select A Sunday")
event.source.date = event.oldValue
# Process If Sunday Selected
if dayOfWeek == "Sun":
# Check if database date range exists
weekExistQuery = "SELECT COUNT (*) AS numRows FROM tblProdSchData WHERE WeekStart = '2015-01-04'"
numRows = system.db.runUpdateQuery(weekExistQuery)
print "Rows:",numRows[/code]