Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the data command

Status
Not open for further replies.

MikeL91

Programmer
Feb 8, 2001
100
US
I am tring to change the data command in inter dev durring run time rather than design time.

Thanks in advance,
Mike
 
let me redefine the question:

I went to the toolbox and droped RecordSet onto my page, then I went to the SQL bulder and created my SELECT statement:

SELECT FNAME,LNAME
FROM customers

now I only want to get the records that match a variable from Request.Form("Lastname") with is called strLastname. I tried:
WHERE LNAME = strLastname

If I am doing this wrong, or you can help with this code, I thanks you in advance.

Thanks
Mike
 
Hi,

You need to make sure that strLastName is outside of the quotes of the select statement:

"Select LName, FName
From Customers
Where LName = " & strLastName

Hope that helps,
ray
 
The SQL does not know about the various fields on your page. strLastName is rather meaningless to the database.

Try using parameters..

Where LName = ?

Then on the last tab of the recordset, specify the Request.Form("LastName"). Or you could specify the parameter value in the recordset_onbeforeopen event..

sub rsMyRecordset_onbeforeopen ()
rsMyRecordset.setParameter 0, Request.Form("LastName")
end sub

The benefit of using parameters is that they cope with embedded quote characters - which normally ruin SQL that is programatically constructed using strings.

(Content Management)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top