Wrox Programmer Forums
.NET Framework 1.x For discussing versions 1.0 and 1.1 of the Microsoft .NET Framework.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 1.x section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 9th, 2010, 06:28 AM
Authorized User
Join Date: Dec 2006
Posts: 43
Thanks: 4
Thanked 0 Times in 0 Posts
Send a message via MSN to Yasho
Default syntax error in update statement

Using visual studio 2003 and access data base, Column password datavalue is set as text. when I run command I get "syntax error in update statement"

CMD As OleDb.OleDbCommand = New OleDb.OleDbCommand
With CMD
.Connection = conSamson
.CommandType = CommandType.Text
.CommandText = "update tblusers set Password = ' " & txtPassword.Text & " ' WHERE FirstName = ' " & txtFirstName.Text & " ';"
Catch ex As Exception
MessageBox.Show(ex.Message, ex.GetType.ToString)
Old September 10th, 2010, 01:57 AM
Friend of Wrox
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts

Try using the following query:
.CommandText = "update tblusers set [Password] = '" & txtPassword.Text & "' WHERE FirstName = '" & txtFirstName.Text & "';"
Om Prakash Pant
Click the "Thanks" button if this post helped you.
Old September 10th, 2010, 04:13 PM
Friend of Wrox
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

And the reason for the change is that PASSWORD is a reserved keyword in JET SQL. By putting it between [...] you are telling JET "use this as a field name, not as a keyword."
The Following User Says Thank You to Old Pedant For This Useful Post:
Yasho (September 21st, 2010)

Similar Threads
Thread Thread Starter Forum Replies Last Post
NEED HELP INSERT INTO statement syntax error koco ASP.NET 1.0 and 1.1 Basics 6 June 2nd, 2006 04:01 PM
Syntax Error in the update statement annie_t Access ASP 1 February 1st, 2005 12:48 PM
Syntax error in INSERT INTO statement. askaggs Classic ASP Databases 5 June 10th, 2004 12:21 AM
UPDATE statement returns syntax error AviatorTim Classic ASP Databases 2 January 8th, 2004 05:22 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.