Log in

View Full Version : Resolved Small SQL problem



romaer
06-14-2009, 12:27 PM
Guys,

I am stacked with what seems to be a very simple problem.
Here is the segment of code I am working on:

fPersonal = request.Form("fPersonalID")
Response.Write(fPersonal)
SQL = "SELECT Alias FROM Personal WHERE PersonalID = fPersonal"
set rs = cn.execute(SQL)
if rs.eof then
response.redirect "wpersonallist.asp?error=1"
else
falias = rs("Alias")
end if

For some reason the code produce the following error:

5
Microsoft JET Database Engine error '80040e10'
No value given for one or more required parameters.
/personalWT/wpersonallist_proc.asp, line 61

As you can see, the variable fPersonal takes a numeric value of 5 but
produces an error. When I replace fPersonal by 5 in the code:
SQL = "SELECT Alias FROM Personal WHERE PersonalID = 5"
everything works.

Please, help
Regards

romaer
06-14-2009, 01:06 PM
Sorry, guys, I have resolved the issue.
It was really too simple.
The SQL statement should be:
SQL = "SELECT Alias FROM Personal WHERE PersonalID = " & fPersonal
Regards