Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 109,157 VB.NET Programmers for FREE! Ask your question and get quick answers from experts. There are 1,028 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Access Update Syntax Error

 
Reply to this topicStart new topic

Access Update Syntax Error

StrategicBlob
post 1 Jul, 2008 - 11:08 AM
Post #1


New D.I.C Head

*
Joined: 26 Jun, 2008
Posts: 2

Hey guys! Blob here with a frustrating code problem. crazy.gif I have an access database that I am trying to update with some "seemingly" simple VB.Net 2008 code. When I try and run this code it links to the cmd.ExecuteNonQuery() and tells me there is a syntax error in my update and the oledb exception was unhandled. Im sure there might be a quote out of place in the update line, but I simply cannot see it, Any ideas??? blink.gif


CODE

Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Documents and Settings\mike.mcgillivry\My Documents\Visual Studio 2008\Projects\Computer Inventory 2\Computer Inventory 2\MINE-Trouble & Inventory.mdb'")

'User is the column of users that each row has
'temp is the name that I want to change to
'Number is the column with the primary key field in my database
'temp11 is the number that links with Number to be searched
'So im trying to say in this update is that if the primary key is the same as the temp11 number, that is the row I
'would like to update. And in the update I want to put temp into the user column field so that the name is updated.

        Dim cmd As System.Data.OleDb.OleDbCommand = conn.CreateCommand()
        cmd.CommandText = "UPDATE [Computer Inventory] SET User='" _
                & temp & "' WHERE (Number='" & temp11 & "') "

        Try
            cmd.Connection.Open()
            cmd.ExecuteNonQuery()
        Finally
            cmd.Connection.Close()
        End Try


This post has been edited by jayman9: 1 Jul, 2008 - 07:34 PM
User is offlineProfile CardPM

Go to the top of the page


dineeshd
post 5 Jul, 2008 - 05:06 AM
Post #2


D.I.C Regular

Group Icon
Joined: 30 Jun, 2008
Posts: 403



Thanked 11 times

Dream Kudos: 575
My Contributions


Hi Blob...

Check out the below link, you may get some help......

http://www.java2s.com/Code/VB/Database-ADO...bConnection.htm
User is offlineProfile CardPM

Go to the top of the page

StrategicBlob
post 11 Aug, 2008 - 07:47 AM
Post #3


New D.I.C Head

*
Joined: 26 Jun, 2008
Posts: 2

QUOTE(dineeshd @ 5 Jul, 2008 - 05:06 AM) *

Hi Blob...

Check out the below link, you may get some help......

http://www.java2s.com/Code/VB/Database-ADO...bConnection.htm



Thanks for the reply dineeshd but I do not believe that helped much crazy.gif
User is offlineProfile CardPM

Go to the top of the page

vbnetskywalker
post 11 Aug, 2008 - 04:14 PM
Post #4


New D.I.C Head

*
Joined: 8 Jun, 2008
Posts: 41



Thanked 1 times
My Contributions


let's try something you don't seem you tried : remove the not needed brackets

try this update statement
CODE

cmd.CommandText = "UPDATE [Computer Inventory] SET User= '"  & temp & "' WHERE Number = '" & temp11 & "'"




hope this hellps
vbnetskywalker
User is online!Profile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/5/08 05:38PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month