Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Wont Add record

    ok. I am trying to write an asp page that will add records to a DB. I am
    trying to get away from using FP for forms and DB's. This is access DB.
    Instead of adding the new record to the DB, it just comes back to the
    register page and doesn't add it. here is the code:

    <%
    Dim Conn

    If Request.Form("action") <> "Save Form Data" Then

    Response.Redirect("register.asp")

    Else
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" &
    Server.MapPath("/tourney/fpdb/tourney.mdb")

    var1 = Request.Form("username")
    var2 = Request.Form("password")
    var3 = Request.Form("email")

    strSQL = "INSERT rounds SET " & var1 & " " & var2 & " " & var3 & ""

    Conn.Execute (strSQL)

    Conn.Close
    Set Conn = Nothing

    response.redirect "players.asp"

    End If

    %>

    here is the register page.. try it. it is supposed to direct to the players
    page located here: [url]http://www.gig-golf.com/Tourney/players.asp[/url]
    can you see something wrong here? I thought I had the script correct, but
    something isn't working.
    thanks
    Jeff

    [url]http://www.gig-golf.com/Tourney/data/register.asp[/url] when you register, it
    SHOULD take you to


    +FarmerPickles Guest

  2. Similar Questions and Discussions

    1. How can i retrieve record ONLY From 300 - 400 in amillion Record Table?
      HI all Thanks for your time.. I have a question here.. How can i retrieve record ONLY From XXX - XXX in a million Record Table? eg. I have a...
    2. Find record w/ conditions met in the same child record
      I'll use 2 files to demonstrate my question. The first file is Animal. It has 4 fields. Id (serial number) ZooId (number) Name (text) Food...
    3. using dropdown box to display db record & update record
      Hi Folks, I have a web database written in asp and using access97. I have many projects, but each project is being held responsible by a person....
    4. Stop adding record in subform after record count = 1
      Can someone help in in what to put after the THEN statment to allow one entry if the Record count is =>1 in the Before insert or should I set the...
    5. Adding a new record when the record source is a query.
      Hello All, I have a form that runs a query. The reason it runs on a query is because prior to it opening I have a form from which you can pick...
  3. #2

    Default Re: Wont Add record

    and before someone asks.. the register page IS posting to the asp page

    "+FarmerPickles" <gig_bam_takemeout_@verizon.net> wrote in message
    news:eviScHqUEHA.1152@TK2MSFTNGP09.phx.gbl...
    > ok. I am trying to write an asp page that will add records to a DB. I am
    > trying to get away from using FP for forms and DB's. This is access DB.
    > Instead of adding the new record to the DB, it just comes back to the
    > register page and doesn't add it. here is the code:
    >
    > <%
    > Dim Conn
    >
    > If Request.Form("action") <> "Save Form Data" Then
    >
    > Response.Redirect("register.asp")
    >
    > Else
    > Set Conn = Server.CreateObject("ADODB.Connection")
    > Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" &
    > Server.MapPath("/tourney/fpdb/tourney.mdb")
    >
    > var1 = Request.Form("username")
    > var2 = Request.Form("password")
    > var3 = Request.Form("email")
    >
    > strSQL = "INSERT rounds SET " & var1 & " " & var2 & " " & var3 & ""
    >
    > Conn.Execute (strSQL)
    >
    > Conn.Close
    > Set Conn = Nothing
    >
    > response.redirect "players.asp"
    >
    > End If
    >
    > %>
    >
    > here is the register page.. try it. it is supposed to direct to the
    players
    > page located here: [url]http://www.gig-golf.com/Tourney/players.asp[/url]
    > can you see something wrong here? I thought I had the script correct, but
    > something isn't working.
    > thanks
    > Jeff
    >
    > [url]http://www.gig-golf.com/Tourney/data/register.asp[/url] when you register, it
    > SHOULD take you to
    >
    >

    +FarmerPickles Guest

  4. #3

    Default Re: Wont Add record

    OK.. let me ask this. i dont need to have a value for each field in the DB
    do i? i need all the other fields remain blank. i have an id field that is
    an auto number, so that shouldnt' matter i dont think.
    Jeff

    "+FarmerPickles" <gig_bam_takemeout_@verizon.net> wrote in message
    news:eBSesLqUEHA.1296@TK2MSFTNGP10.phx.gbl...
    > and before someone asks.. the register page IS posting to the asp page
    >
    > "+FarmerPickles" <gig_bam_takemeout_@verizon.net> wrote in message
    > news:eviScHqUEHA.1152@TK2MSFTNGP09.phx.gbl...
    > > ok. I am trying to write an asp page that will add records to a DB. I am
    > > trying to get away from using FP for forms and DB's. This is access DB.
    > > Instead of adding the new record to the DB, it just comes back to the
    > > register page and doesn't add it. here is the code:
    > >
    > > <%
    > > Dim Conn
    > >
    > > If Request.Form("action") <> "Save Form Data" Then
    > >
    > > Response.Redirect("register.asp")
    > >
    > > Else
    > > Set Conn = Server.CreateObject("ADODB.Connection")
    > > Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" &
    > > Server.MapPath("/tourney/fpdb/tourney.mdb")
    > >
    > > var1 = Request.Form("username")
    > > var2 = Request.Form("password")
    > > var3 = Request.Form("email")
    > >
    > > strSQL = "INSERT rounds SET " & var1 & " " & var2 & " " & var3 & ""
    > >
    > > Conn.Execute (strSQL)
    > >
    > > Conn.Close
    > > Set Conn = Nothing
    > >
    > > response.redirect "players.asp"
    > >
    > > End If
    > >
    > > %>
    > >
    > > here is the register page.. try it. it is supposed to direct to the
    > players
    > > page located here: [url]http://www.gig-golf.com/Tourney/players.asp[/url]
    > > can you see something wrong here? I thought I had the script correct,
    but
    > > something isn't working.
    > > thanks
    > > Jeff
    > >
    > > [url]http://www.gig-golf.com/Tourney/data/register.asp[/url] when you register, it
    > > SHOULD take you to
    > >
    > >
    >
    >

    +FarmerPickles Guest

  5. #4

    Default Re: Wont Add record

    The first step in troubleshooting a non-working query is to see what the
    query is:
    +FarmerPickles wrote:
    <snip>
    > strSQL = "INSERT rounds SET " & var1 & " " & var2 & " " & var3 & ""
    Response.Write strSQL
    Response.End

    Run your page and examine the sql statement printed to the browser window.
    If that does not help you, copy it to the clipboard, open your database in
    Access, go to the Queries tab, create a new query in design view, close the
    Choose Tables dialog without selecting a table, switch to SQL View, paste in
    the sql statement and attempt to run it. You should get a more informative
    error message, given that you've constructed the sql statement incorrectly.

    The correct syntax for an INSERT statement that inserts values into a single
    new row is:

    INSERT (col1,...,colN) VALUES (val1, ..., valN)

    Your Response.Written sql statement should conform to that syntax. In
    addition, you need to quote-delimit string values in the VALUES list, and
    #-delimit date values. I prefer to avoid this hassle by using saved
    parameter queries instead of dynamic sql. A Google search should provide
    several posts I've made on this subject.

    I usually advise people to always use the Access Query Builder to create and
    test your queries before attempting to run them from ASP. In this case,
    however, the Query Builder can only be used for testing, because it does not
    do a good job of creating INSERT...VALUES queries. You have to write the sql
    for those queries yourself.

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows [MVP] Guest

  6. #5

    Default Re: Wont Add record

    "+FarmerPickles" <gig_bam_takemeout_@verizon.net> wrote in message
    news:eviScHqUEHA.1152@TK2MSFTNGP09.phx.gbl...

    : Set Conn = Server.CreateObject("ADODB.Connection")
    : Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" &
    : Server.MapPath("/tourney/fpdb/tourney.mdb")

    To add...

    Considering changing your driver:

    [url]http://able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm#OLEDBProviderForMicrosoftJet[/url]

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - [url]http://www.microsoft.com/technet/scriptcenter/[/url]
    WSH 5.6 Documentation - [url]http://msdn.microsoft.com/downloads/list/webdev.asp[/url]
    MSDN Library - [url]http://msdn.microsoft.com/library/default.asp[/url]


    Roland Hall Guest

  7. #6

    Default Re: Wont Add record

    Ok. I got it to work. was a problem in the sql statement. Anyway.. since
    this is a tournament site... i would like to know how to make it only show
    the most recent entry? i have an autonumber id set, so the latest entry
    would have the higest number.... how can i tell it this? otherwise.. it will
    show all of them.
    Thanks
    Jeff

    i know it would be SELECT * FROM Results Where id is something.. but i am
    not sure :(



    "Roland Hall" <nobody@nowhere> wrote in message
    news:Ospt8BvUEHA.2908@TK2MSFTNGP10.phx.gbl...
    > "+FarmerPickles" <gig_bam_takemeout_@verizon.net> wrote in message
    > news:eviScHqUEHA.1152@TK2MSFTNGP09.phx.gbl...
    >
    > : Set Conn = Server.CreateObject("ADODB.Connection")
    > : Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" &
    > : Server.MapPath("/tourney/fpdb/tourney.mdb")
    >
    > To add...
    >
    > Considering changing your driver:
    >
    >
    [url]http://able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm#OLEDBProviderForMicrosoftJet[/url]
    >
    > --
    > Roland Hall
    > /* This information is distributed in the hope that it will be useful, but
    > without any warranty; without even the implied warranty of merchantability
    > or fitness for a particular purpose. */
    > Technet Script Center - [url]http://www.microsoft.com/technet/scriptcenter/[/url]
    > WSH 5.6 Documentation -
    [url]http://msdn.microsoft.com/downloads/list/webdev.asp[/url]
    > MSDN Library - [url]http://msdn.microsoft.com/library/default.asp[/url]
    >
    >

    +FarmerPickles Guest

  8. #7

    Default Re: Wont Add record

    +FarmerPickles wrote:
    > Ok. I got it to work. was a problem in the sql statement. Anyway..
    > since
    > this is a tournament site... i would like to know how to make it only
    > show
    > the most recent entry? i have an autonumber id set, so the latest
    > entry
    > would have the higest number.... how can i tell it this? otherwise..
    > it will
    > show all of them.
    > Thanks
    > Jeff
    >
    > i know it would be SELECT * FROM Results Where id is something.. but
    > i am
    > not sure :(
    >
    >
    SELECT col1, ..., colN FROM Results
    WHERE ID = (SELECT MAX(ID) FROM Results)

    Don't be lazy: selstar (Select *) should not be used in production code. It
    degrades performance by forcing ADO to make an extra trip to the database to
    translate * into an actual list of columns, and it potentially increases
    network traffic by causing your query to return data that you have no
    intention of using.

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows [MVP] Guest

  9. #8

    Default Re: Wont Add record

    +FarmerPickles wrote:
    > Ok. I got it to work. was a problem in the sql statement. Anyway..
    > since
    > this is a tournament site... i would like to know how to make it only
    > show
    > the most recent entry? i have an autonumber id set, so the latest
    > entry
    > would have the higest number.... how can i tell it this? otherwise..
    > it will
    > show all of them.
    > Thanks
    > Jeff
    >
    > i know it would be SELECT * FROM Results Where id is something.. but
    > i am
    > not sure :(
    >
    Another way of doing it would be this:

    SELECT TOP 1 col1, ..., colN FROM Results ORDER BY Id DESC

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows [MVP] Guest

  10. #9

    Default Re: Wont Add record

    Thx a bunch Bob... got it working... you rock!!
    Jeff



    "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:OmDK8O5UEHA.716@TK2MSFTNGP11.phx.gbl...
    > +FarmerPickles wrote:
    > > Ok. I got it to work. was a problem in the sql statement. Anyway..
    > > since
    > > this is a tournament site... i would like to know how to make it only
    > > show
    > > the most recent entry? i have an autonumber id set, so the latest
    > > entry
    > > would have the higest number.... how can i tell it this? otherwise..
    > > it will
    > > show all of them.
    > > Thanks
    > > Jeff
    > >
    > > i know it would be SELECT * FROM Results Where id is something.. but
    > > i am
    > > not sure :(
    > >
    >
    > Another way of doing it would be this:
    >
    > SELECT TOP 1 col1, ..., colN FROM Results ORDER BY Id DESC
    >
    > Bob Barrows
    >
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >

    +FarmerPickles Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139