This topic is locked

dict in version 6

11/17/2008 5:00:39 PM
ASPRunnerPro General questions
T
Tim author

Hello,
How am I supposed to do this now in version 6?... I am attempting to see if a record exists before I add a new record. Here is the code I have:

strSQLExists = "select * from db_spendingbudget where [SubDepartment]='" & dict("SubDepartment") & "' AND [week] = '" & dict("week") & "'"

set rsExists = CreateObject("ADODB.Recordset")

rsExists.Open strSQLExists, dbConnection
if not rsExists.eof then

response.write "There is already a budget for this subdepartment and week."
BeforeAdd = False
else

BeforeAdd = True
end if

rsExists.Close : set rsExists = Nothing


Is there anything wrong with this code? Maybe in version 6 I'm supposed to use this dal.whatever business... ? (I'm much more comfortable with SQL, but I guess I can learn...). If I am supposed to use dal, what is the syntax for comparing multiple fields?
Also, I've been trying just a simple response.write dict("filedname") to test my stuff and see if I'm going crazy and I can't get anything to display. Has this totally gone away?
Thanks,

Tim

Sergey Kornilov admin 11/18/2008

You can use either SQL or DAL. Both will work just fine.
As a rule of thumb - print your SQL query on the page and test it against your database.

T
Tim author 11/19/2008

Thanks Sergey,
Sorry, I was a bit frustrated at the end of a long day when I made that post. Now, with a clearer head, I have indeed used response.write to check my SQL query and what I found was that I wasn't getting anything returned for dict("week"). This IS a field on the Add page.
It appears that having the field named "week" was the issue. When I gave it an alias it worked fine.
Thanks again,

Tim

Sergey Kornilov admin 11/19/2008

Tim,
makes sense. Week is a function name in MS Access and some other databases.