how to pass values from VB to ASP?

Discussion in 'ASP General' started by Ben, Jun 6, 2004.

  1. Ben

    Ben Guest

    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
    Ben, Jun 6, 2004
    #1
    1. Advertising

  2. 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%...
    > 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
    >
    >
    >
    Martin CLAVREUIL, Jun 6, 2004
    #2
    1. Advertising

  3. Ben

    Ben Guest

    Thanks


    "Martin CLAVREUIL"
    <-dropthis-martin.clavreuil_dropthis_@wanadoo._drop-this_fr> wrote in
    message news:...
    > 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%...
    > > 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
    > >
    > >
    > >

    >
    >
    Ben, Jun 7, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jerry
    Replies:
    20
    Views:
    7,934
    Roedy Green
    Sep 9, 2005
  2. Ahmad Sabry

    get values from asp pass to batch file !!!

    Ahmad Sabry, Nov 22, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    362
    Ahmad Sabry
    Nov 22, 2006
  3. blufox
    Replies:
    2
    Views:
    555
  4. VK

    Pass hidden values in ASP

    VK, Dec 17, 2003, in forum: ASP General
    Replies:
    8
    Views:
    177
  5. VbUser25
    Replies:
    0
    Views:
    107
    VbUser25
    Jan 27, 2005
Loading...

Share This Page