Hi i've got this following error any body knows how to overcome this coz it's waste my 3 hours
Error Type:
Microsoft VBScript compilation (0x800A03F6)
Expected 'End'
line 58
is my if condition have something wrong ?
it's multiple data entry record into the database ? -
<%
-
pnam=Trim(request("txtpname"))
-
Set objConn = Server.CreateObject("ADODB.Connection")
-
objConn.open . . . . MS ACCESS
-
set objrs = server.createObject("ADODB.RecordSet")
-
objrs.open "Select productName from products where productName='" & pnam & "'",objConn,Adopendynamic,Adlockoptimistic
-
if objrs.eof then
-
-
pnam=Trim(request("txtpname"))
-
tdes=Trim(request("txtdesc"))
-
prid=Trim(request("txtpid"))
-
-
if (categ = "") then
-
response.redirect "ul_add.asp"
-
end if
-
-
objrs.Addnew
-
objrs("productName")=pnam
-
objrs("productDesc")=tdes
-
objrs.update
-
-
st2 = Request.Form("10")
-
st3 = Request.Form("12")
-
ct1 = Request.Form("black")
-
ct2 = Request.Form("blue")
-
-
Set Conn = Server.CreateObject("ADODB.Connection")
-
Conn.Open ConString
-
-
If st1 = "10" Then
-
sqlText = "INSERT INTO PRODUCT_SIZES " _
-
& " (size_id, prod_id) values " _
-
& " ('10',"&prid&")"
-
Conn.Execute(sqlText)
-
else if st2 = "12" Then
-
sqlText = "INSERT INTO PRODUCT_SIZES " _
-
& " (size_id, prod_id) values " _
-
& " ('12',"&prid&")"
-
Conn.Execute(sqlText)
-
else if ct1 = "black" Then
-
sqlText = "INSERT INTO PRODUCT_COLOURS " _
-
& " (color_id, prod_id) values " _
-
& " ('black',"&prid&")"
-
Conn.Execute(sqlText)
-
else if ct2 = "blue" Then
-
sqlText = "INSERT INTO PRODUCT_COLOURS " _
-
& " (color_id, prod_id) values " _
-
& " ('blue',"&prid&")"
-
Conn.Execute(sqlText)
-
response.write "New Record save in the Database"
-
else
-
response.write "This Record already in a Database"
-
end if
-
-
objrs.close
-
set objrs= Nothing
-
objConn.Close
-
set objConn = Nothing
-
%>
-
any solution for that ?
9 2799
Look at this block of code... -
If st1 = "10" Then
-
sqlText = "INSERT INTO PRODUCT_SIZES " _
-
& " (size_id, prod_id) values " _
-
& " ('10',"&prid&")"
-
Conn.Execute(sqlText)
-
else if st2 = "12" Then
-
sqlText = "INSERT INTO PRODUCT_SIZES " _
-
& " (size_id, prod_id) values " _
-
& " ('12',"&prid&")"
-
Conn.Execute(sqlText)
-
else if ct1 = "black" Then
-
sqlText = "INSERT INTO PRODUCT_COLOURS " _
-
& " (color_id, prod_id) values " _
-
& " ('black',"&prid&")"
-
Conn.Execute(sqlText)
-
else if ct2 = "blue" Then
-
sqlText = "INSERT INTO PRODUCT_COLOURS " _
-
& " (color_id, prod_id) values " _
-
& " ('blue',"&prid&")"
-
Conn.Execute(sqlText)
-
response.write "New Record save in the Database"
-
else
-
response.write "This Record already in a Database"
-
end if
-
-
Replace it with the following (i pointed out the error here too) -
If st1 = "10" Then '<-- the code is expecting an end to this statement
-
sqlText = "INSERT INTO PRODUCT_SIZES " _
-
& " (size_id, prod_id) values " _
-
& " ('10',"&prid&")"
-
Conn.Execute(sqlText)
-
else if st2 = "12" Then
-
sqlText = "INSERT INTO PRODUCT_SIZES " _
-
& " (size_id, prod_id) values " _
-
& " ('12',"&prid&")"
-
Conn.Execute(sqlText)
-
else if ct1 = "black" Then
-
sqlText = "INSERT INTO PRODUCT_COLOURS " _
-
& " (color_id, prod_id) values " _
-
& " ('black',"&prid&")"
-
Conn.Execute(sqlText)
-
else if ct2 = "blue" Then
-
sqlText = "INSERT INTO PRODUCT_COLOURS " _
-
& " (color_id, prod_id) values " _
-
& " ('blue',"&prid&")"
-
Conn.Execute(sqlText)
-
end if '<---- was missing
-
response.write "New Record save in the Database"
-
else
-
response.write "This Record already in a Database"
-
end if '<--- Is the end to another If statement further up in the code.
-
Sincerely,
Mark
Thx for you kindly reply i've tryied that but the error i've found it on else statment when it's finally going to b finished ?
Line 23 the new code
? ? ? ? ? ? ? i don't know why ?
Regards
Farhan
Thx for you kindly reply i've tryied that but the error i've found it on else statment when it's finally going to b finished ?
Line 23 the new code
? ? ? ? ? ? ? i don't know why ?
Regards
Farhan
Hi , Farhan
Just put the "End If" after Line 25 and see what happens.
Thanks
Hi Fary,
You might want to use Select Case to simplify your code instead of If and ElseIf. That way, (I personally find) it's easier to track any problematic code instead of trying to match opening and closing If... End If statements.
Best regards,
medicineworker
Hi thx for the reply if i'm gonna try the case condition then it's skip few points which i'm trying to save into the database ?
so i just want to store it to selection if condition coz i think so it's more apporiate then case but any thing else is worng ?
coz i've tryed all possiblities but only give this error ?
Error Type:
Microsoft VBScript compilation (0x800A03F6)
Expected 'End'
/shop/admin/ul_confirm.asp, line ( last else statment )?
It may also be your if...else.. statement.
If...else... statements in ASP are not written with a space between them(Else If), they're written together (ElseIf). If they're written apart - I believe ASP may interpret them to be a seperate if statement, which also requires an end if statement. So ASP thinks you've got FOUR if statements here, not one else...if.. and is looking for an end if for all of them. -
If whatever = whatever Then
-
'do whatever
-
Else If whatever <> whatever then
-
'do something else
-
end if
-
-
'the above is the equivelant to the following..
-
-
If Whatever = whatever Then
-
'do whatever
-
Else
-
If whatever <> whatever then
-
'do whatever
-
End If
-
-
'See the missing end if? That's what ASP sees.
-
Try the following code:: -
<%
-
pnam=Trim(request("txtpname"))
-
Set objConn = Server.CreateObject("ADODB.Connection")
-
objConn.open . . . . MS ACCESS
-
set objrs = server.createObject("ADODB.RecordSet")
-
objrs.open "Select productName from products where productName='" & pnam & "'",objConn,Adopendynamic,Adlockoptimistic
-
if objrs.eof then
-
-
pnam=Trim(request("txtpname"))
-
tdes=Trim(request("txtdesc"))
-
prid=Trim(request("txtpid"))
-
-
if (categ = "") then
-
response.redirect "ul_add.asp"
-
end if
-
-
objrs.Addnew
-
objrs("productName")=pnam
-
objrs("productDesc")=tdes
-
objrs.update
-
-
st2 = Request.Form("10")
-
st3 = Request.Form("12")
-
ct1 = Request.Form("black")
-
ct2 = Request.Form("blue")
-
-
Set Conn = Server.CreateObject("ADODB.Connection")
-
Conn.Open ConString
-
-
If st1 = "10" Then
-
sqlText = "INSERT INTO PRODUCT_SIZES " _
-
& " (size_id, prod_id) values " _
-
& " ('10',"&prid&")"
-
Conn.Execute(sqlText)
-
elseif st2 = "12" Then
-
sqlText = "INSERT INTO PRODUCT_SIZES " _
-
& " (size_id, prod_id) values " _
-
& " ('12',"&prid&")"
-
Conn.Execute(sqlText)
-
elseif ct1 = "black" Then
-
sqlText = "INSERT INTO PRODUCT_COLOURS " _
-
& " (color_id, prod_id) values " _
-
& " ('black',"&prid&")"
-
Conn.Execute(sqlText)
-
elseif ct2 = "blue" Then
-
sqlText = "INSERT INTO PRODUCT_COLOURS " _
-
& " (color_id, prod_id) values " _
-
& " ('blue',"&prid&")"
-
Conn.Execute(sqlText)
-
end if
-
response.write "New Record save in the Database"
-
else
-
response.write "This Record already in a Database"
-
end if
-
-
objrs.close
-
set objrs= Nothing
-
objConn.Close
-
set objConn = Nothing
-
%>
-
You wouldn't be able to use a Select case statement here. Select statements check the value of 1 variable, and do different things depending on what the value of that variable is. In each section of your if...else statement here you're checking a different variable, so a case statement would not be effective.
Try the code above and see if it works, the bottom line here is that ASP IS looking for an ending to one of your If statements, you just have to find where. I believe I've found it in the above code... so see if that works.
Sincerely,
Mark
thanks for every body who's replying on this post Marks you've rite if condition has some problem when i use
all together it's execuate all my code but it's only store the 1st value & then next values it's just skip the all values of my program
it mean after taking elseif it's jumped into the last endif statement but i want to use the other as well ?
please any body have some solution how to overcome this problem for the last many dayz i've ?
best regards
Farhan
Yeah, of course it will.
IF...ELSE statements are kind of like saying "If today is saturday, go partying, otherwise.. go to work." Otherwise, being the keyword here.
You're basically saying If st1 = "10" Then - insert a record, otherwise (if st1 does NOT equal "10", then check to see if st2 = "12", if it is... insert a record pertinant to that variable.... If st2 does NOT equal "12" then check to see if ct1 = "black" - if it is, insert a record.. etc etc.
What you want to do is check each one individually.
See the below code. -
<%
-
If st1 = "10" Then
-
sqlText = "INSERT INTO PRODUCT_SIZES " _
-
& " (size_id, prod_id) values " _
-
& " ('10',"&prid&")"
-
Conn.Execute(sqlText)
-
End If
-
If st2 = "12" Then
-
sqlText = "INSERT INTO PRODUCT_SIZES " _
-
& " (size_id, prod_id) values " _
-
& " ('12',"&prid&")"
-
Conn.Execute(sqlText)
-
End If
-
If ct1 = "black" Then
-
sqlText = "INSERT INTO PRODUCT_COLOURS " _
-
& " (color_id, prod_id) values " _
-
& " ('black',"&prid&")"
-
Conn.Execute(sqlText)
-
End If
-
If ct2 = "blue" Then
-
sqlText = "INSERT INTO PRODUCT_COLOURS " _
-
& " (color_id, prod_id) values " _
-
& " ('blue',"&prid&")"
-
Conn.Execute(sqlText)
-
End If
-
%>
-
This is different because it says,
If st1 = "10" - add a record - if it isn't, don't add a record
If st2 = "12" - add a record - if it isn't, don't add a record
If ct1 = "black" - add a record - if it isn't, don't add a record
etc.
Sincerely,
Mark
Hi Marks thx for you replying
and all other how make contribution on this discussion
my coding is working fine thx for the discussion
can you please take a look this code as well any idea about that ? http://www.thescripts.com/forum/thread695688.html
regards
Farhan
Sign in to post your reply or Sign up for a free account.
Similar topics
by: F. Da Costa |
last post by:
Hi all,
Following two sniperts of code I'm using and getting very interesting results from.
..html
<tr id="1" class="segment" open="false">
This is the segment under 'investigation'
..js
|
by: Arpan |
last post by:
<%
If(False) Then
Response.Write("False")
Else
Response.Write("True")
End If
%>
In the above code, the Else condition will be executed. Why?
|
by: kma |
last post by:
I am designing an Access 2000 database on a computer running Windows 98.
I have one form with several tabs; all of which have sub forms, some
with a subform on a subform.
For example, on my...
|
by: Mr. Smith |
last post by:
Hello all,
My code can successfully open, write to, format and save several
worksheets in a workbook then save it by a given name, close and quit excel.
My problem is that if I try and do it...
|
by: dog |
last post by:
I've seen plenty of articles on this topic but none of them have been
able to solve my problem.
I am working with an Access 97 database on an NT4.0 machine, which has
many Access reports.
I...
|
by: Grasshopper |
last post by:
Hi,
I am automating Access reports to PDF using PDF Writer 6.0. I've
created a DTS package to run the reports and schedule a job to run this
DTS package. If I PC Anywhere into the server on...
|
by: TD |
last post by:
This is the code under a command button -
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.BackColor <> RGB(255, 255, 255) Then
ctl.BackColor = RGB(255, 255, 255)
End If
Next ctl
|
by: Andy |
last post by:
and so far I'm loving it, I like the the authors don't beat
around the bush and just come straight out and say what the book
is sopposed to be. They assume the you have computer experience.
I'm...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |