Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP recordsets in a VBscript routine

Status
Not open for further replies.

trimtrom

Programmer
Dec 12, 2003
35
0
0
GB
Hello

I am a beginner ASP programmer, and I am programming a login form as follows:

<form name="frontform" method=POST action="<table align="center" >
<tr><td valign=top>
<label>CostCentre</label></td><td valign=middle><input name="Userniame"><br><br></td>
</tr>
</table>
</fieldset><br>
<button name="pjtbtn" type=button>Submit</button>
</form>

I have a VBscript routine as follows:

<script language=vbscript>
sub pjtbtn_onclick
if len(trim(document.frontform.Userniame.value))=0 then
msgbox "Please enter username"
exit sub
end if
msgbox cstr("<%=strconnect%>")
<%
lstrSQL="Select username, pwd from Login where username = '" + document.frontform.Userniame.value + "'"
objRec.Open lstrSQL,objConn,adOpenDynamic
if not objRec.EOF then
objRec.movefirst
end if
%>
msgbox "cstr(<%=objREC.fields("pwd")%>)"
document.frontform.submit()
end sub
</script>

What I am trying to do is obtain a username from the form, look it up in a recordset objRec (previously opened and connected successfully) in the VBscript routine, and msgbox the corresponding password.

However the browser doesn't seem to like the ASP code in the VBscript routine. Am I allowed to use ASP script in this routine???? "strconnect" refers to the connection string earlier in the page, and that msgboxes OK. It's just the bit referring to the recordset in the VBscript routine that it doesn't like.

I would really appreciate code snippets on how to manipulate the recordset in the VBscript routine!

Many thanks,

Trimtrom
 
You are attempting to write server-side code in your client-side script. This is not possible because the server-side code (ASP) is rendered long before the client-side code is produced and there is no way to pass the ASP values to client-side code as you are attempting to do.

It's still a little early in the morning for me, but why couldn't you just do all of this in an ASP page and ignore the client-side script entirely? Otherwise, you cannot manipulate the recordset (which is done on the server-side) in your VBScript (client-side code).

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
i have posted a complete working code for validatind the form fields in this post thread333-1144611

check it out...and as Chopstik mentioned separate your client-side and server-side code...

let us know if you need more help...

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top