Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - database insert problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

database insert problem

 Post Reply Post Reply
Author
beginner View Drop Down
Newbie
Newbie


Joined: 22 May 2003
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote beginner Quote  Post ReplyReply Direct Link To This Post Topic: database insert problem
    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)%>

 

Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 25 June 2003 at 3:32pm

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

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.