Re: how to pass values from VB to ASP?
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>
"Ben" <teteddd@op> a écrit dans le message de
news:u0qoOR%23SEHA.240@TK2MSFTNGP11.phx.gbl...[color=blue]
> Hi,
>
> When clicking on a button, a new record must be created in an Access[/color]
table.[color=blue]
> 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 &[/color]
"')"[color=blue]
> objconn.execute strsql, , adcmdtext and adcmdexecutenorecords
> %>
> ...
>
> This doen't work. How to pass values inside 'a' and 'b' to ASP?
> Thanks
> Ben
>
>
>[/color] |