This topic is locked
[SOLVED]

 strWhereStatement on Dal

5/16/2011 6:23:51 PM
ASPRunnerPro General questions
B
beachldy author

This is probably a syntax error, as I'm new to using 'DAL'. I'm not getting the strWhereStatement correct, so it seems. I'm using it on a VIEW form, on a button. I can get the first record in the table by omitting the strWhereClause. Sorry if it seems a dumb question.

------------

Dim tmpDict, msg, DriverName

set tmpDict = CreateObject("Scripting.Dictionary")
strWhereClause = (" where [DriverID] = " & Session("DriverID") )

set dalDrivers=dal.Table("tblDrivers")

set data=dalDrivers.Query(strWhereClause,"")

DriverName = data("DriverFName") & " " & data("DriverLName")

------------------

I'd rather use a sql statement, like "Select * from tblDrivers where DriverID = " & Session("DriverID").

Not sure how to use this SQL as I tried this in the form already, using ASP snippet. It didn't work either.
Guess I'm confused about ways to get the data values since looking at all the methods I've seen in posts, help files, etc. It's a bit hard to follow for someone as old as me.

Sergey Kornilov admin 5/17/2011

Both DAL and plain SQL queries work the same way. I guess the main issue here is that Session("DriverID") is not populated. You need to make sure this variable is populated before you use it.

B
beachldy author 5/18/2011

I've tried getting the variable populated using the following but none work:
SchID = Session("SchID")

session("SchID")=Request.Form("SchID")

Session("SchID") = request.querystring("editid1")

Session("SchID") = values("SchID")

Session("SchID") = Request("SchID")
On the Add/Edit pages, I get the variable by using:

SchID = values("SchID"),

which doesn't work in code snippets or buttons. I guess it requires something different?

Sergey Kornilov admin 5/19/2011

Yes, it requires something different. Please check 'Insert PHP/ASP code snippet->Session variables' section at http://xlinesoft.com/blog/2011/04/28/taming-the-beast-events-buttons-and-code-snippets/.
This section explains how to make any field value accessible via Session variables on Edit/View pages.