|
-
Oct 7th, 2000, 08:15 PM
#1
Thread Starter
Member
Hi, I am making a kind-of admin-site for a site and haven't dealt with asp much before.
My problem:
First of all, this is how Im thinking:
------------------
*if the names from the form is NOT empty, do the following:
**if the first-name and the last-name from the form exists in the database Response.write:
That person is already added.
**if the names do NOT match the one in the database, add the person and his/her info in the database and response.write:
You have successfully added (the person)
**if the name-fileds were empty, response.write:
you forgot to fill in the name, please try again.
------------------
What's not working is if I try to add a person that already is in the database it creates a new
line in it with the info, and I do not want that to happen.
Code:
<!-- #include file="../db/adovbs.inc" -->
<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
<LINK REL="STYLESHEET" TYPE="text/css" HREF="rstr.css"></STYLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="2">
<TR>
<TD CLASS="Heading" COLSPAN="7">
<%
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("../db/roster.mdb")
Set RS = Server.CreateObject("ADODB.Recordset")
Addera = "SELECT * FROM teamROSTER"
RS.Open Addera, Connect, adOpenStatic, adLockOptimistic
Dim fNamn,eNamn,JerseyNr,Pos,height,weight,born,city
fNamn = Request.Form("fNamn")
eNamn = Request.Form("eNamn")
JerseyNr = Request.Form("Nr")
Pos = Request.Form("pos")
height = Request.Form("height")
weight = Request.Form("weight")
born = Request.Form("born")
city = Request.Form("city")
IF fNamn <>"" AND eNamn <>"" THEN
DO UNTIL RS.EOF
IF fNamn = RS("fNamn") AND eNamn = RS("eNamn") THEN
Response.write("<B>" & fNamn &" " & eNamn & "</B> is allready in the teamROSTER<BR></TD>")
EXIT DO
ELSEIF fNamn <> RS("fNamn") AND eNamn <> RS("eNamn") THEN
RS.AddNewRS("fNamn") = fNamn
RS("eNamn") = eNamn
RS("JerseyNr") = Jersey
NrRS("pos") = Pos
RS("Height") = Height
RS("Weight") = Weight
RS("Born") = Born
RS("Birthplace") = City
Response.write(RS("fNamn") & " " & RS("enamn") & " has been added to the teamROSTER<BR><BR></TD>")
EXIT DO
ELSE Response.write("")
END IF
RS.MoveNextLoop
ELSEIF fNamn = "" AND eNamn="" THEN
Response.write("You must fill in at least the players First and Last name<BR></TD>")
ELSE
Response.write("</TD>")
END IF
%>
</TR>
<TR>
<TD CLASS="TD1"><A HREF="teamROSTER.asp">View teamROSTER</A><BR></TD>
</TR>
</TABLE>
<%
RS.Update
RS.Close
Connect.Close
%>
</BODY></HTML>
This is the error-message I'm getting:
Error Type:
Provider (0x80020005)
Type mismatch.
/rstr/teamROSTER_added.asp, line 41
And that shows that one of the IF's does not work, it tries to add the person despite he/she already is in the db.
I'm getting that error-message cause I, on purpose, left a field blank.
Even though that field is empty that part of the code should NOT be executed.
does anyone of you see something wrong in the code above ??
I really need help with this, I've stared my self almost blind on this problem for hours...
thanks,
David
"There are no must's in life unless you provide for someone else than yourself"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|