how to pass values from VB to ASP?

B

Ben

Hi,

When clicking on a button, a new record must be created in an Access table.
See my code:

<%
set objdc = Server.CreateObject("ADODB.Connection")
objdc.Open("provider=Microsoft.Jet.OLEDB.4.0; Data Source
=c:\access\mydb.mdb")
%>

<html><head><title></title></head><body>
<INPUT id=test TYPE="button" value="go">

<script language=vbscript>
sub test_onclick()
a=inputbox ("enter your name")
b=inputbox("enter your email")
end sub
</script>

<%
strsql = "insert into mytable (name, email) values('" & a & "','" & b & "')"
objconn.execute strsql, , adcmdtext and adcmdexecutenorecords
%>
....

This doen't work. How to pass values inside 'a' and 'b' to ASP?
Thanks
Ben
 
M

Martin CLAVREUIL

hi,

ASP is a server side scripting techno. VBS is a client side one.
This mean you can't invert or mix their use on on side.
In order to insert a new record you'll have to create 2 files. (simplest
method)

This file is the form :
<FILE1.htm>
<html>
<body>
<form action="FILE2.asp" method="POST">
Value #1 : <input name="val_a"><br>
Value #1 : <input name="val_b">
</form>
</body>
</html>
</FILE1.htm>

And this one insert (server-side) the record in the DB :
<FILE2.asp>
<%
a=request.form("val_a")
b=request.form("val_b")
set objdc = Server.CreateObject("ADODB.Connection")
objdc.Open("provider=Microsoft.Jet.OLEDB.4.0; Data Source
=c:\access\mydb.mdb")
odjdc.Execute "INSERT INTO MyTable values(" & a & ", " & b & ")"
%>
<html>
<body>
Record inserted
</body>
</html>
</FILE2.asp>
 
B

Ben

Thanks


"Martin CLAVREUIL"
hi,

ASP is a server side scripting techno. VBS is a client side one.
This mean you can't invert or mix their use on on side.
In order to insert a new record you'll have to create 2 files. (simplest
method)

This file is the form :
<FILE1.htm>
<html>
<body>
<form action="FILE2.asp" method="POST">
Value #1 : <input name="val_a"><br>
Value #1 : <input name="val_b">
</form>
</body>
</html>
</FILE1.htm>

And this one insert (server-side) the record in the DB :
<FILE2.asp>
<%
a=request.form("val_a")
b=request.form("val_b")
set objdc = Server.CreateObject("ADODB.Connection")
objdc.Open("provider=Microsoft.Jet.OLEDB.4.0; Data Source
=c:\access\mydb.mdb")
odjdc.Execute "INSERT INTO MyTable values(" & a & ", " & b & ")"
%>
<html>
<body>
Record inserted
</body>
</html>
</FILE2.asp>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top