Print Page | Close Window

database insert problem

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=3830
Printed Date: 30 March 2026 at 5:00am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: database insert problem
Posted By: beginner
Subject: database insert problem
Date Posted: 25 June 2003 at 1:52pm

I am having problems with this code but i'm not sure what is wrong with it. The error that i get is "Expected 'End'".

Here is the cod ei hope someboyd can help me.

<%FName = Request.Form("FName")
  LName = Request.Form("LName")
  Title = Request.Form("Title")
  role = Request.Form("role")
  phone = Request.Form("phone")
  email = Request.Form("email")
  cell = Request.Form("cell")
  contactType = Request.Form("ContactType")
  if contactType = "AgencyContact" then
 contactType="1"
  else if contactType = "TechnicalContact" then
 contactType="2"
  end if
Submit = Request.Form("submit")

if (Submit is "next") then
 Response.Redirect "agencyForm2.asp"
else if (Submit is "back") then
 Response.Redirect "agencyForm.asp"
end if
Dim Cn, strSQL
    Set Cn = Server.CreateObject("ADODB.Connection")
    Cn.Open Application("Connection3_ConnectionString")
    strSQL = "INSERT INTO Contacts(FirstName, LastName, title, Responsibilty, PhoneNum, email, Pager_Cell, ContactTypeId, AgencyId)"
    strSQL =strSQL & "Values('"&FName&"', '"&LName&"', '"&Title&"', '"&role&"', '"&phone&"','"&email&"','"&cell&"','"&Session("Username")&"')"
    Cn.Execute(strSQL)%>

 




Replies:
Posted By: Gullanian
Date Posted: 25 June 2003 at 2:34pm

what error are you getting?

try:

  strSQL =strSQL & " Values('"&FName&"', '"&LName&"', '"&Title&"', '"&role&"', '"&phone&"','"&email&"','"&cell&"','"&Session("Username")&"')"

 

I think you might need a gap



Posted By: MorningZ
Date Posted: 25 June 2003 at 2:48pm

Instead of

if (Submit is "next") then
 Response.Redirect "agencyForm2.asp"
else if (Submit is "back") then
 Response.Redirect "agencyForm.asp"
end if

use

if (Submit is "next") then
 Response.Redirect "agencyForm2.asp"
elseif (Submit is "back") then
 Response.Redirect "agencyForm.asp"
end if

"elseif" is one word in Vbscript land.. also higher up, changing:

else if contactType = "TechnicalContact" then
to:
elseif contactType = "TechnicalContact" then

and btw, the error will tell you exactly what line of code to look at



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: pmormr
Date Posted: 25 June 2003 at 3:32pm

using else if starts a new if block, thats why your getting the error "expected 'end'"



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net