Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
.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
Display Modes
  #1 (permalink)  
Old September 9th, 2010, 06:28 AM
Authorized User
 
Join Date: Dec 2006
Location: Tucson, AZ, USA.
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"

[Code}
Dim
CMD As OleDb.OleDbCommand = New OleDb.OleDbCommand
Try
conSamson.Open()
With CMD
.Connection = conSamson
.CommandType = CommandType.Text
.CommandText = "update tblusers set Password = ' " & txtPassword.Text & " ' WHERE FirstName = ' " & txtFirstName.Text & " ';"
.ExecuteNonQuery()
EndWith
Catch ex As Exception
MessageBox.Show(ex.Message, ex.GetType.ToString)
EndTry
[/code]
__________________
yvk
Reply With Quote
  #2 (permalink)  
Old September 10th, 2010, 01:57 AM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

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

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."
Reply With Quote
The Following User Says Thank You to Old Pedant For This Useful Post:
Yasho (September 21st, 2010)


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


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.