|
here it is:
If some condition Then
oRS.Open .....
Do something with oRS
End If
oRS.Close Depending on whether the above if-block was executed or not, this close statement may generate the error. My mistake!
oRS.Open NewSQLStatement
...
...
...
Thanks!
norm
|
|
|
|
|
I would be grateful if folk could spare a few moments to visit my newest website.
It is designed to be local to one area of Scotland but as the logs show we are getting hits from around the world I would love some feedback!
http://www.angusblog.co.uk[^]
Thanks,
Davy
Weblog, Ramblings and more...
www.latedecember.com
|
|
|
|
|
Wait( ) for VBScript?
I need something that do this:
Wait(2000) --- wait 2000 ms before executing next line of code.
anyone? Thanks.
norm
|
|
|
|
|
There isn't any such function in VBScript.
You can get around it though by using SetTimeout. This allows you to designate a delay before executing a sub or function.
So if you structure your code suitably you can do this
sub myFirstSub()
'Do whatever
MsgBox("test1")
Call SetTimeout("mySecondSub", 2000)
end sub
sub mySecondSub()
MsgBox("test2")
'Do something else
end sub
the first parameter to SetTimeout is the name of the function or sub you want to execute, the second is the delay in milliseconds that you want. So in my
example when i call myFirstSub I will get a messagebox with "test1" then 2 seconds later I get another messagebox with "test2".
HTH
|
|
|
|
|
|
Can I use object.Sleep instead? I tried it.. no error, but it seems that it didnt work:
SetTimer... hum, I dont think it post/submit the form variables.
I need to do this, but for some reason it seems that it didnt "Sleep" as instructed. Here's the fragment:
<% Response.Write "It takes time to read this message" %> HERE: This message need to stay on screen.
Object.Sleep 5000 PROBLEM: No error, but it seems like the page didnt actually waited 5000 millisec? The page just got redirected right away it seems. the user didnt get a chance to read the above msg at all.
<% If (bExistingLogin="1" Or bSuspended="1" Or bEMailPrevReg="1") Then %>
window.history.go(-1)
<% Else %>
Login()
<% End If %>
Thanks.
norm
|
|
|
|
|
I'm not quite sure what you mean by it not posting form variables. But if you mean you want the login function to post a form to another page, then you can do it like this:
<%="This is a message"%>
<script language="VBScript">
call SetTimeout("timedFunc", 5000)
sub timedFunc
<%If (bExistingLogin="1" Or bSuspended="1" Or bEMailPrevReg="1") Then %>
history.go(-1)
<%else%>
call Login()
<%end if%>
end sub
sub Login()
frmLogin.submit()
end sub
</script>
<form name="frmLogin" action="2.asp" method="post">
<input type="hidden" name="username" value="Torsten">
</form>
basically you just need to prepopulate the form with whatever form variables you want to post.
if this isn't what you're trying to do then could you please be a bit more specific about what you want and i'll help you further. If you like you can email me a copy of your source and i'll take a look at it for you.
HTH
|
|
|
|
|
Basically, I just need to add a time delay at one point in my script before executing the rest:
<% Response.Write "A message takes TIME to read %> I NEED TO HAVE THIS MSG STAY ON SCREEN FOR 1000 milli-sec.
Sleep(1000)
<%
ExecuteTheRest()
%>
That's all I want to do. And the following is the actual code:
<title>.....
...
Sub Login()
document.redirect_login_form.submit
End Sub
...
... some hidden variables here...
...
...
...
...
<%
Response.Write "CAN YOU SEE THIS MESSAGE?"
Response.Flush()
%>
<% If (bExistingLogin="1" Or bSuspended="1" Or bEMailPrevReg="1") Then %>
window.history.go(-1)
<% Else %>
Login()
<% End If %>
SYMTOMS:
Client side error: "object required WScript..." and I have no idea why...
So, I tried:
Object.Sleep 50000 (I think I remember seeing this somewhere...)
window.Sleep 50000 (Yes, "window" does not support this method)
Reference (WScript):
1. http://www.tek-tips.com/gviewthread.cfm/lev2/4/lev3/32/pid/329/qid/395765
2. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsmthappactivate.asp
3. http://www.aspalliance.com/steven.swafford/articles/defrag.aspx
I have also tried using setTimeout in place of Sleep... Got an error message saying "cannot use parentheses when calling a sub"
Sub WasteTime()
End Sub
window.setTimeout("WasteTime()",30000)
I tried too many things... I cant remember if there's an client side error..but I think the page got redirected as if setTimeout did NOT have any effect of the execution of my ASP page.
Help!
norm
|
|
|
|
|
Try this code:
<head></head>
<body>
...
<script Language="VBScript">
Sub Login()
document.redirect_login_form.submit
End Sub
</script>
...
<form name=redirect_login_form method="post" action="login_gui.asp">
... some hidden variables here...
</form>
...
...
...
...
<%
Response.Write "CAN YOU SEE THIS MESSAGE?"
Response.Flush()
<script language="VBScript">
call setTimeout("delayedSub", 1000)
sub delayedSub()
If (bExistingLogin="1" Or bSuspended="1" Or bEMailPrevReg="1") Then %>
window.history.go(-1)
<% Else %>
Login()
<% End If %>
end sub
</script>
</body>
That should be all you need to do.
the reason you are getting an error with setTimeout is because in VBScript you need to add the "call" keyword before a sub call if you use the parentheses. otherwise VBScript thinks it is a function.
i.e. you can call a sub in two ways:
1. subname param1, param2
2. call subname(param1, param2)
If you're still stuck after this then feel free to email me a copy of your code and I will fix it and annotate the fixes for you which might be a bit clearer then a forum post.
HTH
|
|
|
|
|
I found a solution, and just to help out those of you who may ...
<%
Sub Delay(DelaySeconds)
SecCount = 0
Sec2 = 0
While SecCount < DelaySeconds + 1
Sec1 = Second(Time())
If Sec1 <> Sec2 Then
Sec2 = Second(Time())
SecCount = SecCount + 1
End If
Wend
End Sub
%>
<% Delay(7) %>
norm
|
|
|
|
|
a silly ASP question...
How come I cant use Server.Transfer("somepage.html") in block, but I can use them in <% %> block?
norm
|
|
|
|
|
Also, it seems that Sub GoHome() must be done in <script> block - <% %> wont do...???
Here's the code that calls
<tr
OnMouseOver="this.bgColor='LightSteelBlue'"
OnMouseOut="this.bgColor='Ivory'"
OnMouseDown="GoHome()">
<td align=center>Home</td>
</tr>
Any idea?
Thanks!
norm
|
|
|
|
|
norm wrote:
How come I cant use Server.Transfer("somepage.html") in block, but I can use them in <% %> block?</i>
I cannot be sure of my conclusion without more info, but I think you are suffering from classic Server vs. Client Side confusion.
<code><% %></code> are <em>server side</em> script block definers. That means any script inside that block will be run server side, not client side.
<code><script> </script></code> blocks are typically client side. So any code in those blocks are run client side, not server side.
<code>Server</code> is an ASP object, accessible only on the server side, not the client side. So you cannot have client side code trying to access the <code>Server</code> object, as it does not exist client side.
<div style="padding-left:36px;font:10px verdana;color:#fff;width:200px;border:dashed 1px #069;height:40px;background:#036 url(http://stormfront.bluegrassgroup.com/proudlysa.jpg) no-repeat 2px 1px;"><strong>Paul Watson</strong><br>Bluegrass<br>Cape Town, South Africa</div>
<small><b>Roger Wright wrote:</b></small>
<i>Using a feather is kinky; using the whole chicken is perverted!</i>
|
|
|
|
|
Thanks. That's clear things up a lot!
norm
|
|
|
|
|
Can you all make any suggestions on ASP .NET web hosts with SQL Server support in US? I've seen several, but they don't seem to have greatest value.
Thanks.
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Brinkster[^] are great value for money, in my opinion, I have two accounts with them... for over a year, I had three.
Depends how cheap you consider to be value though and what service you expect in return.
Paul
Pleasently caving in, I come undone - Queens of the Stone Age, No One Knows
|
|
|
|
|
Seems like everybody has SQL Server as a per month add-on plus setup. I'm used to the linux world of web hosting where you get a MySQL database already available and configured with no setup fees. To me that is a value, but I suppose that is asking too much in the realm of windows where there are licenses involved.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
perlmunger wrote:
I suppose that is asking too much in the realm of windows where there are licenses involved
Absolutely. If it were free then the cost of the licence would be split across all users. Why should I pay for your SQL Server if I only need Access?
Brinkster used to offer 10Mb of SQL Server as part of the package and loads of people complained, so they split it off.
Paul
Pleasently caving in, I come undone - Queens of the Stone Age, No One Knows
|
|
|
|
|
I guess it makes sense. I'm spoiled in the sense that I've used free software so long that I expect a lot for nothing. On the other hand, I am pretty dang tired of not having stored procedures, sub-selects, and transactions in MySQL. So I guess what I was paying for from MySQL was nothing except a simple data store. I suppose the adage is true in this case as well--you get what you pay for. It's probably time to pony up. Argh!!
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
I want to be able to swap items betwen two list boxes using JavaScript. It's a bit like a web version of the "Select recipients" window in outlook express when you can add people to different list boxes such as "To", "CC", "BCC".
+-----+ [ + Add ] +-----+
| | | |
| | | |
| | | |
| | | |
| | | |
+-----+ [ - Remove] +-----+
Add and Remove are just simple buttons that call some JavaScript when pressed. Also when an item is added to one list box it should be deleted from the other.
I know of loads of code to do this in MFC (I think there's an example on this site), but anyone got any pointers on how I'd do it in JavaScript please? I can work it out, but it would be nice if some nice person helped me and saved me a bit of time!
I feel like I'm diagonally parked in a parallel universe
Jeremy Davis
http://www.astad.org http://www.jvf.co.uk
|
|
|
|
|
Here are some things that I have found out by trial and error about using JavaScript with the HTML <select> element:
To access the <select>:
document.formName.selectName
To clear all of the <option>'s from the <select>:
document.formName.selectName.options.length = 0;
To add an <option> to a <select>:
var newOption = document.createElement("OPTION");
document.formName.selectName.options.add(newOption);
To remove an <option> from a <select>:
document.formName.selectName.options[i] = null;
To deselect <option>(s) in a <select>:
document.formName.selectName.selectedIndex = -1;
This should give you the basics to run with this ... and I am sure there is plenty of examples out there ... just don't have a link handy.
Wally Atkins Newport News, VA, USA
|
|
|
|
|
here's a couple of functions i wrote to do this.
function moveListItem(eleFrom, eleTo)
{
var i = 0;
var IDX = 0;
var arrMovIDX = new Array();
var startIDX = 0;
var arrRemIDX = new Array();
for(i = 0; i < eleFrom.options.length; i++)
{
if(eleFrom.options[i].selected)
{
arrMovIDX[IDX] = eleFrom.options[i];
arrRemIDX[IDX] = i;
IDX += 1;
}
}
startIDX = eleTo.options.length;
for(i = 0; i < arrMovIDX.length; i++)
{
eleTo.options.length += 1;
eleTo.options[startIDX].text = arrMovIDX[i].text;
eleTo.options[startIDX].value = arrMovIDX[i].value;
startIDX += 1;
}
for(i = eleFrom.options.length - 1; i > -1; i--)
{
if(eleFrom.options[i].selected)
{
eleFrom.options[i] = null;
}
}
}
function moveAllListItems(eleFrom, eleTo)
{
var i = 0;
for(i = 0; i < eleFrom.options.length; i++)
{
eleFrom.options[i].selected = true;
}
moveListItem(eleFrom, eleTo);
}
basically just create your buttons and add the appropriate function call to the appropriate button.
e.g. to move from left to right you would call "moveListItem(formname.leftList, formname.rightList);"
moveListItem will move only selected items (supports multiple selections)
moveAllListItems does exactly that.. it will move all the options from one list to another.
if you have any trouble implementing these the give me a shout and i'll provide an example.
HTH
|
|
|
|
|
|
|
Can I put a "Search the Website" facility on ASP pages and the search box page being used as an include file on rest of the website.
Please help and also if its possible, can you guide how it can be done?
|
|
|
|