Syntax error in UPDATE statement- asp/jscript

R

Robert Mark Bram

Hi All!

I have the following two methods in an asp/jscript page - my problem is that
without the update statement there is no error, but with the update
statement I get the following error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
/polyprint/dataEntry.asp, line 158

I fail to understand why there is a syntax error - I am pretty sure all of
the parameters to the Open method are ok..

Any advice would be most welcome!

Rob
:)

function modifyNewsletter()
{
var _newsletter = getParameter ("edition");
var _language = getParameter ("language");

var sql = "SELECT * " +
"FROM newsletterText " +
"WHERE (((newsletterText.pageName)='" + _newsletter + "') " +
"AND ((newsletterText.language)='" + _language + "')) " +
"order by newsletterText.paragraph asc";

var newsletterText = getRecordSetForModifyingRecords (sql);

while (!newsletterText.EOF)
{
Response.Write (newsletterText ("text") + " --- " +
newsletterText ("style") + "<br>");

newsletterText ("text") = "changed...";

// problem statement
newsletterText.Update;

Response.Write (newsletterText ("text") + " --- " +
newsletterText ("style") + "<br>");


newsletterText.MoveNext();
} // end while


// Gets a recordset for modifying records.
// Uses the adLockOptimistic lock and accepts an sql statement.
function getRecordSetForModifyingRecords (sql)
{
var rs = Server.CreateObject ("ADODB.Recordset");
rs.Open (sql, // Source
polyprintConnection, // ActiveConnection
adOpenForwardOnly, // CursorType
adLockOptimistic); // LockType
return rs;
} // end getRecordSetForModifyingRecords function
 
S

Stuart Palmer

Try response.writing your variable sql to the screen and see what the lines
says, try and post that as a query directly into access and see if it gives
you anything.

It could be something to do with the way you are breaking up the sql
statement (like missing a space accidently) so put it all in one line for
the moment might help and then when you are done, then you can break it up.

I don't know about JS with serverside stuff, but in vbscript you should put
something like

sql = "SELECT * "sql = sql +
sql = sql + "FROM newsletterText "sql = sql +
sql = sql + "WHERE (((newsletterText.pageName)='" + _newsletter + "') "sql
= sql +
sql = sql + "AND ((newsletterText.language)='" + _language + "')) "sql =
sql +
sql = sql + "order by newsletterText.paragraph asc"

Not saying any of these things are the prob, but may help trouble shoot the
issues you are seeing.

Good luck

Stu
 
R

Ray at

Where's line 158? And what does Response.write(sql) show you for the SQL
query just before that line?

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top