|
-
Apr 13th, 2010, 06:38 AM
#1
Thread Starter
New Member
[RESOLVED] syntax error in update statement
i'm using this code to try and write a value to a table in an access database. when i try to execute this code i get the error "syntax error in UPDATE statement" i really need help with this and realise its probably a really simple problem but could you please help. if you need any of my other code etc to help then just ask 
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUPdate.Click
Dim myConnection As OleDb.OleDbConnection
Dim ds As New DataSet
myConnection = New OleDb.OleDbConnection
Dim myDataAdapter As OleDb.OleDbDataAdapter
Dim myTable As String = "Authentication"
myConnection.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = " & dbFilePath
myConnection.Open()
Dim sql As String = "Select * from " & myTable
myDataAdapter = New OleDb.OleDbDataAdapter(sql, myConnection)
Dim cb As New OleDb.OleDbCommandBuilder(myDataAdapter)
myDataAdapter.Fill(ds, "myTable")
myConnection.Close()
temp = txtNew.Text
temp2 = ds.Tables("myTable").Rows(0).Item(1)
If txtUser.Text = ds.Tables("myTable").Rows(0).Item(0) Then
If txtOld.Text = temp2 And txtNew.Text = txtConfirms.Text Then
encrypt()
ds.Tables("myTable").Rows(0).Item(1) = temp
' error message on next line
myDataAdapter.Update(ds, "myTable")
MsgBox("password updated")
Else
MsgBox("passwords did not match")
End If
Else
MsgBox("Username is incorrect")
End If
End Sub
-
Apr 13th, 2010, 06:59 AM
#2
Re: syntax error in update statement
did you set the update statement ? did you made sure the parameters is not empty (null) ?
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Apr 13th, 2010, 07:02 AM
#3
Thread Starter
New Member
Re: syntax error in update statement
the tutorial i was using, this one >>>> http://www.homeandlearn.co.uk/NET/nets12p10.html didn't tell me too. but also reading on msdn it seemed to say that for simple one table updates you didn't need to set an update statment
-
Apr 13th, 2010, 07:47 AM
#4
Re: syntax error in update statement
Welcome to VBForums 
Given that your code includes the words "username" and "password", I strongly suspect that one or more of your table name/field names are reserved words, and as such should not be used as a field/table name (it confuses the query parser within the database system).
For more information (including lists of words), see the article What names should I NOT use for tables/fields/views/stored procedures/...? from our Database Development FAQs/Tutorials (at the top of this forum)
-
Apr 13th, 2010, 07:52 AM
#5
Thread Starter
New Member
Re: syntax error in update statement
thank you very much that solved it you have no idea how long i've been trying to fix that XD
-
Apr 13th, 2010, 08:20 AM
#6
Re: [RESOLVED] syntax error in update statement
you are closing the connection during update. Close the connection only after the .update method.
Please mark you thread resolved using the Thread Tools as shown
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|