Ask a Question related to ASP Database, Design and Development.
-
+FarmerPickles #1
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
-
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... -
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... -
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.... -
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... -
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... -
+FarmerPickles #2
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...players> 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> 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
-
+FarmerPickles #3
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...but> 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...> players> > 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> > 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,>> > 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
-
Bob Barrows [MVP] #4
Re: Wont Add record
The first step in troubleshooting a non-working query is to see what the
query is:
+FarmerPickles wrote:
<snip>Response.Write strSQL> strSQL = "INSERT rounds SET " & var1 & " " & var2 & " " & var3 & ""
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
-
Roland Hall #5
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
-
+FarmerPickles #6
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...[url]http://able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm#OLEDBProviderForMicrosoftJet[/url]> "+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://msdn.microsoft.com/downloads/list/webdev.asp[/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 -> MSDN Library - [url]http://msdn.microsoft.com/library/default.asp[/url]
>
>
+FarmerPickles Guest
-
Bob Barrows [MVP] #7
Re: Wont Add record
+FarmerPickles wrote:
SELECT col1, ..., colN FROM Results> 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 :(
>
>
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
-
Bob Barrows [MVP] #8
Re: Wont Add record
+FarmerPickles wrote:
Another way of doing it would be this:> 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 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
-
+FarmerPickles #9
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



Reply With Quote

