Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 01:39 PM
Ben
Guest
 
Posts: n/a
Default how to pass values from VB to ASP?

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



  #2  
Old July 19th, 2005, 01:39 PM
Martin CLAVREUIL
Guest
 
Posts: n/a
Default 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]


  #3  
Old July 19th, 2005, 01:40 PM
Ben
Guest
 
Posts: n/a
Default Re: how to pass values from VB to ASP?

Thanks


"Martin CLAVREUIL"
<-dropthis-martin.clavreuil_dropthis_@wanadoo._drop-this_fr> wrote in
message news:O09BnoATEHA.3552@TK2MSFTNGP09.phx.gbl...[color=blue]
> 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=green]
> > Hi,
> >
> > When clicking on a button, a new record must be created in an Access[/color]
> table.[color=green]
> > 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=green]
> > objconn.execute strsql, , adcmdtext and adcmdexecutenorecords
> > %>
> > ...
> >
> > This doen't work. How to pass values inside 'a' and 'b' to ASP?
> > Thanks
> > Ben
> >
> >
> >[/color]
>
>[/color]


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles