469,312 Members | 2,524 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,312 developers. It's quick & easy.

Cannot Find Error on this ASP

M P
Hi Team!

Hope that you could help me! Its been days since I made this script but I
cannot fix the problem! IE is prompting me that there is a Syntax Error but
it seems that the syntax is OK! Can you help me find the problem?

Note the fields PartNo and ItemDesc is the only text data type on my MS
Access database.
<%
Dim strSQL

Set conn= Server.CreateObject("ADODB.Connection")
conn.Open "FileDSN=dsn.dsn"
strSQL= "INSERT INTO tblItems
(PartNo,ItemDesc,Category,MinStockLevel,Cost,Curre ncy) "
strSQL= strSQL & "Values('" & Request.Form("txtPN") & "', '"
strSQL= strSQL & Request.Form("txtItemDesc") & "', "
strSQL= strSQL & Request.Form("txtCategory") & ", "
strSQL= strSQL & Request.Form("txtMinStock") & ", "
strSQL= strSQL & Request.Form("txtCost") & ", "
strSQL= strSQL & Request.Form("txtCurrency") & ")"

conn.Execute strSQL

conn.Close

%>
Jul 19 '05 #1
5 1498
I could be wrong but, the error appears to be with the following 2 lines;

<second line>
strSQL= strSQL & "Values('" & Request.Form("txtPN") & "', '"

<last line>
strSQL= strSQL & Request.Form("txtCurrency") & ")"

You've got a ' after Values( and at the end with the comma, but there's no
matching one at the end of the last line (closing the ")" )

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
M P <ma**@textguru.ph> wrote in message
news:uQ**************@TK2MSFTNGP12.phx.gbl...
Hi Team!

Hope that you could help me! Its been days since I made this script but I
cannot fix the problem! IE is prompting me that there is a Syntax Error but it seems that the syntax is OK! Can you help me find the problem?

Note the fields PartNo and ItemDesc is the only text data type on my MS
Access database.
<%
Dim strSQL

Set conn= Server.CreateObject("ADODB.Connection")
conn.Open "FileDSN=dsn.dsn"
strSQL= "INSERT INTO tblItems
(PartNo,ItemDesc,Category,MinStockLevel,Cost,Curre ncy) "
strSQL= strSQL & "Values('" & Request.Form("txtPN") & "', '"
strSQL= strSQL & Request.Form("txtItemDesc") & "', "
strSQL= strSQL & Request.Form("txtCategory") & ", "
strSQL= strSQL & Request.Form("txtMinStock") & ", "
strSQL= strSQL & Request.Form("txtCost") & ", "
strSQL= strSQL & Request.Form("txtCurrency") & ")"

conn.Execute strSQL

conn.Close

%>

Jul 19 '05 #2
Before:
conn.Execute strSQL

Do this:

<%
Response.Write(strSQL)
Response.End

conn.Execute strSQL
%>

and you will see your SQL statement printed to the screen. Examine it for
errors, or post it here.

Cheers
Ken
"M P" <ma**@textguru.ph> wrote in message
news:uQ**************@TK2MSFTNGP12.phx.gbl...
: Hi Team!
:
: Hope that you could help me! Its been days since I made this script but I
: cannot fix the problem! IE is prompting me that there is a Syntax Error
but
: it seems that the syntax is OK! Can you help me find the problem?
:
: Note the fields PartNo and ItemDesc is the only text data type on my MS
: Access database.
:
:
: <%
: Dim strSQL
:
: Set conn= Server.CreateObject("ADODB.Connection")
: conn.Open "FileDSN=dsn.dsn"
: strSQL= "INSERT INTO tblItems
: (PartNo,ItemDesc,Category,MinStockLevel,Cost,Curre ncy) "
: strSQL= strSQL & "Values('" & Request.Form("txtPN") & "', '"
: strSQL= strSQL & Request.Form("txtItemDesc") & "', "
: strSQL= strSQL & Request.Form("txtCategory") & ", "
: strSQL= strSQL & Request.Form("txtMinStock") & ", "
: strSQL= strSQL & Request.Form("txtCost") & ", "
: strSQL= strSQL & Request.Form("txtCurrency") & ")"
:
: conn.Execute strSQL
:
: conn.Close
:
: %>
:
:
Jul 19 '05 #3
Hi M

Assuming you've copied and pasted this text, then the issue will be with your SQL string (starting with "strSQL ="). On this line you've missed the ending " & _, so it should look like this

strSQL= "INSERT INTO tblItems" &

and on each line of the string thereafter you have the trailing ", but not the required & _. This is how it should be

Set conn= Server.CreateObject("ADODB.Connection"
conn.Open "FileDSN=dsn.dsn
strSQL= "INSERT INTO tblItems" &
(PartNo,ItemDesc,Category,MinStockLevel,Cost,Curre ncy) " &
strSQL= strSQL & "Values('" & Request.Form("txtPN") & "', '" &
strSQL= strSQL & Request.Form("txtItemDesc") & "', " &
strSQL= strSQL & Request.Form("txtCategory") & ", " &
strSQL= strSQL & Request.Form("txtMinStock") & ", " &
strSQL= strSQL & Request.Form("txtCost") & ", " &
strSQL= strSQL & Request.Form("txtCurrency") & ")

In any command or string in VBScript, if you want to break a single line statement up from one line into multiple, you need to add a underscore (_) to the end of the line. This is the character VBScript uses to indicate the next line is a continuum of the current line

Cheer
Lai

Jul 19 '05 #4
jon
Ensure that the non-text values do actually contain a numeric value, otherwise you will be posting back a blank - which will cause an error. Try adding a check function to ensure this i.e.

Function ConvNo(pNo)

If IsNumeric(pNo) Then
ConvNo = Cdbl(pNo)
Else
ConvNo = 0
End if

End Function

Then call this on each of the numeric field as:

ConvNo(Request.Form("txtCurrency"))

This will ensure that 0 is passed rather than "" on an expected numeric entry.

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Jul 19 '05 #5

"Lain" <an*******@discussions.microsoft.com> wrote in message
news:C9**********************************@microsof t.com...
Hi M P

Assuming you've copied and pasted this text, then the issue will be with your SQL string (starting with "strSQL ="). On this line you've missed the
ending " & _, so it should look like this:
strSQL= "INSERT INTO tblItems" & _

and on each line of the string thereafter you have the trailing ", but not the required & _. This is how it should be:
Set conn= Server.CreateObject("ADODB.Connection")
conn.Open "FileDSN=dsn.dsn"
strSQL= "INSERT INTO tblItems" & _
(PartNo,ItemDesc,Category,MinStockLevel,Cost,Curre ncy) " & _
strSQL= strSQL & "Values('" & Request.Form("txtPN") & "', '" & _
strSQL= strSQL & Request.Form("txtItemDesc") & "', " & _
strSQL= strSQL & Request.Form("txtCategory") & ", " & _
strSQL= strSQL & Request.Form("txtMinStock") & ", " & _
strSQL= strSQL & Request.Form("txtCost") & ", " & _
strSQL= strSQL & Request.Form("txtCurrency") & ")"
In any command or string in VBScript, if you want to break a single line statement up from one line into multiple, you need to add a underscore (_)
to the end of the line. This is the character VBScript uses to indicate the
next line is a continuum of the current line.
Cheers
Lain


True enough but he's not breaking the line up !!

so he doesn't need the &_

Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by David T. Ashley | last post: by
2 posts views Thread by karinmorena | last post: by
reply views Thread by =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post: by
reply views Thread by =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.