ADO Record Object - Test For Last Iteration (VBScript)
I have a record object (for instance, named record). I record.MoveFirst, then I set up a simple little loop:
For Each ofield in record.Fields
...
Next
Within my loop, I want to test to see if it is the last iteration. That is, with a simple If...Then, I want to be able to complete something the last time through.
Is this possible, either with some sort of record.EOF type property, or some sort of record.Count type property (and then using a simple counter during iteration to count down until the last one)?
I'd like to try to be at least a little elegant... I understand its possible to iterate through the whole record twice, the first time to count, but that would obviously be a poor choice if any other method is available.
The current code (see below) works. But, I wonder if there's better way to test if a node object has something or not.
<% ... ' want to find if /Root/Node's id attribute is 1, ' if yes: get its child node <num> Dim nodeA : Set nodeA = xmlDoc.selectSingleNode("/Root/Node[@id='1']/num") ' test if nodeA have something If TypeName(nodeA) = "Nothing" Then ' -- NO: nodeA has nothing Else ' -- TypeName is "IXMLDOMElement" ' -- YES: nodeA has something End If ... %>
I have tried other functions, such as IsEmpty(), IsNull(), IsObject(): none can get the result I wanted.
I am building a shopping cart where orders are send by email. Even though it says it's sent, I receive nothing. So I did a test script to send an email using CDO since we are using an exchange server for email and it's on the same network as the site. Code:
Can I loop through a recordset and with each record, see if the value of a field is higher than 5. If it higher than 5, just delete that record, not the whole record set and continue the loop.
I am accustomed to using a sql statement to selecting an entire recordset based on similar criteria and deleting the whole recordset in one swoop, but not this time. Code:
in javascript attempting to get a string from somewhere sometimes will give you a string reading "undefined" or "object" now i know that this sort of thing happens in vbscript too, if i'm writing a universal "convert anything to a string" function what do i need to check for so that anything like "undefined" or "null" (or NULL) get's converted into ""?
I am trying to use the following code to refer to a form and control on my form. I am supposed to be using VBSCRIPT for this code. I always get an "object required: 'document' " error:
<% Dim Myform Set Myform = document.forms.thisform Myform.textbox1.value = "fish" %>
None of this code will work. Always get an error. Using Visual Interdev, plain ole ASP, and vbscript, and Win XP Pro with IIS 5.1
dim oShell set oShell=WScript.CreateObject("WScript.shell") oShell.run ("C:WINNTsystem32cmd.exe /c C:WINNTsystem32 otepad.exe") set oShell=nothing
works as expected in the context of a .vbs script and doesn't work (with the following changes made...) when inserted in a .asp web page under IIS ?
dim oShell set oShell=Server.CreateObject("WScript.Shell") ' intReturn = oShell.run ("C:WINNTsystem32cmd.exe /c C:WINNTsystem32 otepad.exe") response.write(intReturn) set oShell=nothing
the Shell object is well created (i can check some of its properties) but the oShell.run command doesn't seem to execute the given command line.
I've discovered an insidious bug with the VBScript Regular Expression object.I set the pattern to consist of the set of invalid filename characters plus comma. I set global property to true then do a replace on a SID. The Replace does nothing. However, if I attach the C++ (dev studio 2003) debugger to the IIS host process (dllhost.exe), every time I call RegExp.Replace, the stack for one of the process's threads gets scrambled. It ends up with the value 0x00000001 at the top of the stack! If your debugger is set to stop on access violations, it always catches one (invalid read trying to delete). The problem is insidious because, without the debugger running, you would never know this is happening. ASP returns no error. Potentially this could wreak havoc on your web application and cause bizarre failures later on. Has anyone else run into this one? It seems to happen only with the Replace method.
I have almost completed tweaking vbscript to run on mysql rather than the Access database it was designed for. Trial and error, luck and a bit of detective work have got me this far, however I am getting the following error when tryinf to update existing records in the database.
Microsoft VBScript runtime error '800a01b6' Object doesn't support this property or method: 'RS.Find' /faq/admin/edit2.asp, line 7
The .Find text is black whereas all other "methods"(?) like the .Open are pink. Is it that the .Find method works with access and not mysql and if so waht is the equivalent or am I barking up the wrong tree?
I have always used this in ASP to test if the client is accepting cookies:
<%@language="VBScript"%> <% Session ("nc") = 1 If Len(Session("nc")) = 0 Then 'Cookies Off Else 'Cookies On End If %>
But I only ever tested it in Microsoft Internet Explorer 6 though not sure. Anyway with Microsoft Internet Explorer 5.5 SP2 Len(Session("nc")) <> 0 always whether cookies are on or off. Can anyone suggest a better cookie test that will work in most browsers?
I have a PC running Win XP Home and want to learn how to write ASPs. In order to test them I think I need a web server installed on my PC. Since I don't believe IIS can be run under Win XP Home I downloaded and installed the Apache web server. I'm stuck at this point and would appreciate opinions on whether I am on the right track, and, if so, advice on the following. 1. Having written a test asp page how do I use Apache to test it? 2. Can Apache handle VBScript on an ASP page? From the info on the Apache web site I don't think it can.
iam making asp test engin and i dont want the user to use the keyboard so is there a way to disable the keyboard of the computer that have the exam on ? its not a website world wide. i will make it on my room computers. is it possible ?
What I have is a ASP test script that can grade online tests and give the test results at the bottom of the test page itself. What I need is the test results to be passed on to a test results page with the score of the test that was taken. I have a problem getting the test results intact over to the test results page.
I have an asp script which is posted to by a form. On the script I need to know if cookies are enabled.
Therefore I need to make the form post to a different script which sets a cookie and does a response.redirect to the main script. However, how to I make the request object get forwarded to the second script with the response.redirect?
You cannot use server.transfer as the test for cookies will not work properly.
In ASP VBScript,is there a way to programmatically test if a SQL Server database server is alive?
I want to use a connection string to a mirrored DB server in case the primary DB server fails. This failover is easy in ASP.NET, which supports DB mirroring and a the specification of a secondary server in its data provider.I want to hack together the same thing for my classic ASP apps.
anyone know some good ASP code to go through a page and test the hyperlinks to make sure that they are valid. Couldn't find anything good yet, but if someone knows of anthing.
How to I test a varable to see if it contains a number and not a text value?I want to use this to detect if people have edited my get strings in the URL field of the browser, before it gets send to the next page.
I am sure it is simple just forgot, had a search on yahoo and could not find anything.
Well i use Timer to test ASP scripts how much time is needed for rendering. But how much time, approximately a heavy asp project like CMS or FORUM should do?
I am creating an application for online test in ASP.While taking test i want functionality as on brainbench when we take any test there. Only difference i want is that there will be 5 questions in my test to be solved in 10 minutes.And all 5 will appear on one page. I am done with other parts.but i am unable to find the logic for restricting time.And dont know what logic should i implement so that timer should not start again even when he goes back and returns to the page again.I have used javascript timer.
But i want the answer value to be a value from a database. Is that possible? value="request.querystring("Answer2") Where Answer2 is the field name? Is that wrong?
And for the code to check if it's right i want it to be able to compare it to a value in the database. (CHECK.ASP) Code:
A client wants to include a news page on his site . This would change basically weekly. I have tried to explain basic HTML ie headers etc but he cannot or does not want to understand.
Is there a way to say for him to create a word file or equivalent with nicely Bolded coloured headers etc. There will only be three or four news items a week.
I need to dynamically generate some submit buttons = the easy part . But i'm not sure how i can test which button has been used to submit the form and what it's value is . Anyone know this?
I made a small javaScript that checks and see if the user has .NET installed on his computer... but the problem is that I HAVE .NET, so I can not check that it works when you do not have .NET.
can someone that does not have .NET installed on his computer, go to the following URL and let me know that he gets a correct reply? (that he does not have .NET).
I have a left menu that is accessed and displayed via XMLHTTP (it resides on the same server). Some sections of the web site don't have a "menu.asp", so a "Page Not Found" page is returned, which doesn't look great in the menu column.. Is there a way to know if a page exists before using xml.responseText to pull it?
I have a company web site which has asp pages and html pages. We have build a new site and I am doing QA for that. How can I test that web site to check if all the links work fine. there are so many links and I can not click each and every one. Is there good automation tool.