how to pass values from VB to ASP?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben

    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.CreateOb ject("ADODB.Con nection")
    objdc.Open("pro vider=Microsoft .Jet.OLEDB.4.0; Data Source
    =c:\access\mydb .mdb")
    %>

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

    <script language=vbscri pt>
    sub test_onclick()
    a=inputbox ("enter your name")
    b=inputbox("ent er your email")
    end sub
    </script>

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

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



  • Martin CLAVREUIL

    #2
    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.a sp" method="POST">
    Value #1 : <input name="val_a"><b r>
    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.CreateOb ject("ADODB.Con nection")
    objdc.Open("pro vider=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%23S EHA.240@TK2MSFT NGP11.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.CreateOb ject("ADODB.Con nection")
    > objdc.Open("pro vider=Microsoft .Jet.OLEDB.4.0; Data Source
    > =c:\access\mydb .mdb")
    > %>
    >
    > <html><head><ti tle></title></head><body>
    > <INPUT id=test TYPE="button" value="go">
    >
    > <script language=vbscri pt>
    > sub test_onclick()
    > a=inputbox ("enter your name")
    > b=inputbox("ent er your email")
    > end sub
    > </script>
    >
    > <%
    > strsql = "insert into mytable (name, email) values('" & a & "','" & b &[/color]
    "')"[color=blue]
    > objconn.execute strsql, , adcmdtext and adcmdexecutenor ecords
    > %>
    > ...
    >
    > This doen't work. How to pass values inside 'a' and 'b' to ASP?
    > Thanks
    > Ben
    >
    >
    >[/color]


    Comment

    • Ben

      #3
      Re: how to pass values from VB to ASP?

      Thanks


      "Martin CLAVREUIL"
      <-dropthis-martin.clavreui l_dropthis_@wan adoo._drop-this_fr> wrote in
      message news:O09BnoATEH A.3552@TK2MSFTN GP09.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.a sp" method="POST">
      > Value #1 : <input name="val_a"><b r>
      > 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.CreateOb ject("ADODB.Con nection")
      > objdc.Open("pro vider=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%23S EHA.240@TK2MSFT NGP11.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.CreateOb ject("ADODB.Con nection")
      > > objdc.Open("pro vider=Microsoft .Jet.OLEDB.4.0; Data Source
      > > =c:\access\mydb .mdb")
      > > %>
      > >
      > > <html><head><ti tle></title></head><body>
      > > <INPUT id=test TYPE="button" value="go">
      > >
      > > <script language=vbscri pt>
      > > sub test_onclick()
      > > a=inputbox ("enter your name")
      > > b=inputbox("ent er your email")
      > > end sub
      > > </script>
      > >
      > > <%
      > > strsql = "insert into mytable (name, email) values('" & a & "','" & b &[/color]
      > "')"[color=green]
      > > objconn.execute strsql, , adcmdtext and adcmdexecutenor ecords
      > > %>
      > > ...
      > >
      > > This doen't work. How to pass values inside 'a' and 'b' to ASP?
      > > Thanks
      > > Ben
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...