Solved

If statement in SQL Query

Posted on 2014-03-13
4
268 Views
Last Modified: 2014-03-13
Hi Experts,
How could I place the If statement below in the where clause of an SQL query?

WHERE Emp_Id = <%If not rs1.EOF or NOT rs1.BOF Then Response.Write(rs1("Emp_Id")) Else Response.Write (Emp_Id) End If%>

I would appreciate your help.
0
Comment
Question by:romsom
  • 2
4 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39927960
Without any context...

If not rs1.EOF or NOT rs1.BOF Then Emp_Id = rs1("Emp_Id")

"SELECT
...
WHERE Emp_Id =" & Emp_Id

Open in new window

0
 
LVL 5

Expert Comment

by:Joe Jenkins
ID: 39927963
Any more context you can provide?  I try not to dynamically insert items into the SQL string like that.  

If there is only expected to be a single variable in that recordset, then why not just load the contents of that recordset into an ASP variable and put that in there.  

Perhaps if we could see some more code around this, including how you are getting the recordset data, we could probably optimize this code some more.
0
 
LVL 5

Expert Comment

by:Joe Jenkins
ID: 39927964
I see Gary tossed a comment in there while I was typing my response.  I agree with his code without any context.
0
 

Author Closing Comment

by:romsom
ID: 39927969
This is perfect, thank you very much!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now