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
%> 5 1556
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
%>
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
:
: %>
:
:
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
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...
"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 &_ This discussion thread is closed Replies have been disabled for this discussion. Similar topics
8 posts
views
Thread by baustin75 |
last post: by
|
10 posts
views
Thread by Jean-David Beyer |
last post: by
|
reply
views
Thread by SampathTangudu |
last post: by
|
1 post
views
Thread by Peter |
last post: by
|
3 posts
views
Thread by David T. Ashley |
last post: by
|
reply
views
Thread by Curious |
last post: by
|
4 posts
views
Thread by GHUM |
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
| | | | | | | | | | |