I have a code for executing a stored procedure and returning a recordset wrapped in an IF statement. If the statement is true the code executes. If the statement is false the code is skipped.
On the page, I want to display a message if the Recordset returned from the stored procedure is empty.
<% If rs.BOF or rs.EOF Then %>
Message
<% End If %>
Running the above code will return an error message if the recordset object doesn't exist...i.e. if the stored procedure hasn't executed and returned the recordset object.
How can I write the code to include that condition?
URLURLI need help writiing an advanced conditional statement.I want to display an image if two recordset values = 1 or other various number combinations.
This statement works with one, how could I edit this statement to include two recordsets values? Say I want to add another feild say "recent" to this statement and it has a value of 2
Code:
<% if Recordset1.Fields.Item("progress").Value = 1 then ' Adv Conditional Region %> <% end if ' Recordset1.Fields.Item("progress").Value = 1 %>
I'm just trying to figure out what the colon : does in this code:
<%If (Not isNull(COLOR)) Then If (COLOR = "Blue") Then Response.Write("SELECTED") : Response.Write("")
I thought it may be the ASP version of the Ternary operator, but it doesn't have the same effect. Is it just another way to concatenate? or a reverse concatenate? or maybe a addition of an empty string to make sure that the output from the response.write statement is a string and not a number?
If the second response statement has a value then it prints it e.g. Code:
I am trying to do a simple "less than" conditional statement, and hitting a brick wall if I use a database element with it.
This DOES work: <% if Request.QueryString("PC") < 10 then Response.Write("less than ten") else Response.Write("more than or equal to ten") End if %>
This DOES NOT work: <% if Request.QueryString("PC") < Record.Fields.Item("count(*)").Value then Response.Write("less than COUNT") else Response.Write("less than or equal to count") End if %
I have a ton of dynamic pages that I need an asp conditional to run on.I know the urls of all the pages and I want to know if there is an easy way to write a conditional statement that if they are on a specific page that it outputs something depending on the url they are on. Is there an easy way to do this?
I have the following simple conditional on my page,
If EmpIDError <> 1 Then 'Show Input items End If
Now I need to add another conditional to this,
If PosIDError <> 1 Then 'Show input items End If
So I made it like this,
If EmpIDError <> 1 OR PosIDError <> 1 Then
But the problem is that if PosIDError = 1, then it still shows the input items. But if I take the EmpIDError <> 1 out then it works with no problems. Why would this be like this?
i have an simple invoice sheet and in "total" coloumn i need to put a formula like IF < 8.50 THEN VALUE =8.50.it is something like we dont do delivery less then 8.50 so if the TOTAL is less than 8.50 then it should turn in to 8.50 automatically.
One of my asp pages can be loaded in two ways - it may be submitted to itself (and therefore contains user data) or it can be loaded by clicking on a link on my menu, and consequently all fields are empty.
If the fields contain values (ie. the submit button was pressed), i want to load data from my database into an array, but if it is accessed via a link, i don't want this data to be loaded. So essentially, i want to know if there is some form of conditional compilation or something in asp (i know it technically shouldn't be called that, but i'm coming from a c++ background, so...) similar to the #if and #elif type directives in C
I can't place the code in a subprogram and selectively call it, because I want the arrays to be global so all my client-side scripts can access the data I'm using VBScript for the asp scripting.
I have a shopping cart that I want to load items in that come from a huge scrolling form. In other words, when someone clicks on a category in our site, it scrolls out all the items in that category, maybe 30 or more. I have text boxes next to each item so somone can enter a number, then press submit form button at the bottom of the form, and send those slections to the shopping cart.
The problem is, many of the text boxes are empty, yet they are still being sent to the shopping cart as a quatity of 0. Is there a way for sql to ignore a value if the variable is zero, or only get the sql statement to run if a variable is > 0?
I am not too sure wats wrong w the if-else statement below!
<%if(grp==grp2)%> { <%if (start==req || end==req)%> { <%=grp%> <%=start%> <%=end%> } <%else%> { <%="There is no such record found"%> } } <%else%> { <%="There is no such record found!"%> } <%endif%>
I have a 'primary' intranet website and a 'secondary' backup of this site as well. I would like to programmatically have the effect that if the primary site is (page not found 404) not available, for it to access the secondary site or at least be able to add a message with (or instead of) the 404 error dialog that the primary site is down and give the user a link to the alternative (secondary) site.
This is probably a simple question, but how does one format a table such that if a field is a certain value, then it will have a specific color.
For example, in the code below, if the specific field named "Year" is '2004' then I want it to appear in red, otherwise it should appear in black. Code:
return all of the exact matches Jon Doe (user uses quotes to clarify an exact search) along with that: return all of the James and all of the Doh as well qry to look like this as soon as I am able to divide up the string entered in by the user select * from table where (NAME LIKE '%Jon Doe%') or (NAME LIKE '%James%') or (NAME LIKE '%Doh%')
Thinking of using the instr to find the " but then what do I do to find the string inside of the two quotes, One quote would be easy. there is a couple of checks to preform:anyone run into this before or have any ideas/samples, etc
I have created a query wizard page with ddl as your choice to find info. now each ddl has a default of a dash.
The thing is I want to do is have the sql statement to look through the database even when some of the ddl have a dash on them. or just ignore the ones with a dash and look for the ones that are selected. Is there any suggestions for this.
Below is my code for a question system i have created. However, i need to insert an if statement that redirects the user to test.asp if the value of q_id is not in my database, but i dont know how to do it?
<% q_id = request("q_id")
sql = "SELECT * FROM questions WHERE PARENT_ID = 1" Set objRS2 = Server.CreateObject("ADODB.Recordset") objRS2.Open sql, objConn
sql_sql = "SELECT * FROM questions WHERE PARENT_ID = " & q_id Set objRS3 = Server.CreateObject("ADODB.Recordset") objRS3.Open sql_sql, objConn
i make a form with an AccountId box on it , when u enter the accountid in the box , and submit it will send u to a page that show u all the data for this accountid(retreive data)
until here everything is ok , and when i enter for ex. accountid : 5 , all the aacountid fiel data will be show to me , but the problem when i enter am unvalid accountid , it will give the error page that
what iwant to do that i want when i enter an unvaildaccountid an error text show to me like
response.write("The Id that u entered is unvaild , Try Again")
and this is the code , if u can change on it Code:
I am trying to use the following IF statement, and whenever I use a single or double quote, I receive a syntax error. When using no quotes, the syntax is accepted, but the statement does not perform properly.
***The problem line*** <% if violation_type=''Tardy'' THEN %> ***rest of the statement*** TARDY VIOLATIONS <% if rs2.Fields(0) = 0 THEN %> This is the first unexcused Tardy violation for this employee. A coaching is required. Click <A HREF=blah>HERE</Ato issue the coaching. <% ELSE %> This employee has <%response.write(rs2.Fields(0))%previous violations. <% END IF %> <% ELSE %> The <%response.write(violation_type)%violation has been recorded. <% END IF %>
On a page with a form (post method) and a hidden field "Process value = true", why would this statement not work:
<% if request.Form("Process") = "true" THEN The code in here sends an email to the user via CDOSYS End IF %>
This is what I have going on and it does not send the emal when the form is posted. Removing the If statement obviously sends the email the moment the form page is accessed, but thats not right.
i have a couple of if statements and it goes something like this, the user will try entering their username and password in the login page then they will be taken to a verify page, then it will decided if the user can be send to the login page again or to the invalid page. The problem is that after 3 times the user is still send to the login page and not the invalid page My verify page code is :- <% session("try") = try if try = "" then try = 0 else try = try + 1 end if if try <> 3 then response.redirect("login.asp") else response.redirect("invalid.asp") end if
Recordset1.Source = "SELECT `bestsellerslists`.`itemnumber`, `bestsellerslists`.`list`, `products`.`Product_ID`, `products`.`Product_Name`, `products`.`Price`, `products`.`Sale_Price`, `products`.`Smallpic` FROM `bestsellerslists` INNER JOIN `products` ON (`bestsellerslists`.`itemnumber` = `products`.`Product_ID`) WHERE (`bestsellerslists`.`list` = "girlinfant")"
In Macromedia, the recordset tests fine. When I start the page, I get an error. Do you see anything wrong with this? If I delete the WHERE clause it works.
I'm having a problem with my variables. They print to screen fine, but when I try comparing them, they don't work. Can anyone tell me what I'm doing wrong?
If Category <> CurrentCategory then response.write "<tr><td>Category:" & Category & "</td></tr>" response.write "<tr><td>CurCategory:" & CurrentCategory & "</td></tr>" else response.write "<tr><td>hello</td></tr>" End If
I am passing in values either customer id (key) or their names (name) from a form . You don't have to use both the id and the name to search for the customer however I don't know how to do this! If the keyform = "" then , use the name to find the customer else can't find it! this is what I have at the moment :
keyForm = Trim(request("key")) name Form = Trim(request("name ")) Dim name , cyfeiriad, tref, sir, codpost, ebost, ffon, cyfrif, dyddiad Set dnsSQL = g_con.Execute("SELECT key_user_accounts,name ,cyfeiriad,tref,sir,codpost,ebost,ffon,cyfrif,dydd iadcreucyfrif from cwsmeriaid Where key_user_accounts = " & keyForm & " if not name = "" then and name = '" & nameForm & "'") else ") end if
ii am using a statement to send a query to the SQL server and i am getting errors like expected end of statement. what might be the problem and do i use a statement like this for dynamically assign values or it's better to use stored procedures.
dim mySQL="Select * from logindetails where loginname='" & logname & "'"