\r\n\r\n
Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET Database and Reporting > Syntax Error in UPDATE statement


\r\n \r\n
 
 
Thread Tools Display Modes

\r\n\r\n\r\n
Background: VB6(w/Service Pack 5), Windows XP, Access 2000
\r\n
\r\nJust read a basic ADO tutorial here, but as I inputed the code I was informed of a Syntax Error in the following line:
\r\n
\r\nMyConn.Execute ("UPDATE Users(User Name) VALUES(\'Ben\')")
\r\n
\r\nIn my database, I have a table named Users, and a column named User Name.
\r\n
\r\nIdeally, I want this code to add a new row and input a string in the appropriate field. But after numerous errors, I have scaled it down to a simple update command, and still recieve a syntax error. What am I doing wrong?
\r\n
\r\nFull Code:
\r\n
\r\nDim MyConn As ADODB.Connection
\r\nDim strPath As String
\r\n
\r\nPrivate Sub cmdNew_Click()
\r\n
\r\nstrPath = App.Path
\r\nSet MyConn = New ADODB.Connection
\r\n
\r\nMyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & "\\Nascar.mdb;"
\r\n
\r\nMyConn.Open
\r\n
\r\nMyConn.Execute ("UPDATE Users(User Name) VALUES(\'Ben\')")
\r\n
\r\nMyConn.Close
\r\nEnd Sub
\r\n \r\n\r\n
\r\n \r\n\r\n \r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n
\r\n \r\n \r\n \r\n \r\n Reply With Quote\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n \r\n\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n'; pd[654374] = '\r\n\r\n \r\n\r\n
\r\n
\r\n
\r\n\r\n
\r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n \r\n
\r\n
\r\n  \r\n #2  \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n
\r\n \r\n Old\r\n \r\n 02-17-2004, 01:59 PM\r\n \r\n \r\n \r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n
00100b\'s Avatar\r\n\r\n
\r\n \r\n 00100b\r\n 00100b is offline\r\n\r\n\r\n
Prev Previous Post   Next Post Next
  #1  
Old 02-17-2004, 01:47 PM
challandler challandler is offline
Newcomer
 
Join Date: Jun 2003
Posts: 6
Question Syntax Error in UPDATE statement


Background: VB6(w/Service Pack 5), Windows XP, Access 2000

Just read a basic ADO tutorial here, but as I inputed the code I was informed of a Syntax Error in the following line:

MyConn.Execute ("UPDATE Users(User Name) VALUES('Ben')")

In my database, I have a table named Users, and a column named User Name.

Ideally, I want this code to add a new row and input a string in the appropriate field. But after numerous errors, I have scaled it down to a simple update command, and still recieve a syntax error. What am I doing wrong?

Full Code:

Dim MyConn As ADODB.Connection
Dim strPath As String

Private Sub cmdNew_Click()

strPath = App.Path
Set MyConn = New ADODB.Connection

MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & "\Nascar.mdb;"

MyConn.Open

MyConn.Execute ("UPDATE Users(User Name) VALUES('Ben')")

MyConn.Close
End Sub
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax Error In Update Statement MadMaxx Database and Reporting 6 12-12-2003 10:38 AM
SQL Update Statement syntax error smartens Database and Reporting 1 11-18-2003 05:30 AM
Syntax error in update statement Louie Database and Reporting 10 11-04-2003 06:41 PM
Syntax error in UPDATE statement - Pls Help Burnard Database and Reporting 1 06-25-2003 10:23 AM
syntax error in update statement mcm Database and Reporting 1 02-08-2003 06:02 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->