9 Replies - 5274 Views - Last Post: 26 September 2012 - 12:33 PM

#1 timosilver  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 115
  • Joined: 20-March 11

help with INSERT INTO statement

Posted 16 September 2012 - 12:42 AM

Hello

Am doing a reset password form
i want to update the current password with new one on the password field.
 Dim SQL2 As String
                    Dim objCmd As New OleDbCommand
                    Dim username As String
                    Dim newpass As String

                    username = TextBox4.Text
                    newpass = TextBox2.Text

                    SQL2 = "INSERT INTO logintable where username=TextBox4.Text VALUES ('" & username & "', '" & newpass & "',)"

                    cmd = New OleDbCommand(SQL2, conn)
                    objCmd = New OleDbCommand(SQL2, conn)
                    objCmd.ExecuteNonQuery()


Is This A Good Question/Topic? 0
  • +

Replies To: help with INSERT INTO statement

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8937
  • View blog
  • Posts: 33,462
  • Joined: 12-June 08

Re: help with INSERT INTO statement

Posted 16 September 2012 - 03:36 AM

It would think you would want to use the SQL UPDATE statement and not the INSERT when it comes to "update the current password with new one".
Was This Post Helpful? 1
  • +
  • -

#3 timosilver  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 115
  • Joined: 20-March 11

Re: help with INSERT INTO statement

Posted 16 September 2012 - 09:32 PM

thanks
Was This Post Helpful? 0
  • +
  • -

#4 timosilver  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 115
  • Joined: 20-March 11

Re: help with INSERT INTO statement

Posted 16 September 2012 - 09:55 PM

so i have below code. showing syntax error. can you help me correct the code? thanks
SQL2 = "UPDATE logintable SET password = '" & TextBox2.Text & "'  WHERE username= '" & TextBox4.Text & "' "

Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8937
  • View blog
  • Posts: 33,462
  • Joined: 12-June 08

Re: help with INSERT INTO statement

Posted 16 September 2012 - 10:00 PM

Would you be more specific on the text of the error?
Was This Post Helpful? 0
  • +
  • -

#6 timosilver  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 115
  • Joined: 20-March 11

Re: help with INSERT INTO statement

Posted 16 September 2012 - 10:07 PM

"Syntax error in update statement"
Was This Post Helpful? 0
  • +
  • -

#7 June7  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 104
  • View blog
  • Posts: 904
  • Joined: 09-December 08

Re: help with INSERT INTO statement

Posted 20 September 2012 - 06:58 PM

The .Text is the wrong property (.Value is correct, but .Value is the default property so don't even need to type it). However, that should not cause the SQL to fail. I don't see anything wrong with the SQL syntax. Just to be safe, enclose table and field names in [].

This post has been edited by June7: 20 September 2012 - 06:59 PM

Was This Post Helpful? 0
  • +
  • -

#8 timosilver  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 115
  • Joined: 20-March 11

Re: help with INSERT INTO statement

Posted 20 September 2012 - 09:18 PM

thanks June7. i can get what you mean. but i tried below code.. same broblem.

                    meusername = TextBox4.Text
                    newpass = TextBox2.Text

                    SQL2 = "UPDATE logintable SET password = '" & meusername & "'  WHERE username= '" & newpass & "' "


Was This Post Helpful? 0
  • +
  • -

#9 June7  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 104
  • View blog
  • Posts: 904
  • Joined: 09-December 08

Re: help with INSERT INTO statement

Posted 22 September 2012 - 02:57 PM

You have the variables paired with the wrong fields. Which textbox has username and which has password?

You are still using .Text. It is the wrong property. Maybe it will make a difference if you omit it.

Step debug. Are the variables getting populated? Reference http://www.cpearson....excel/debug.htm

This post has been edited by June7: 22 September 2012 - 03:01 PM

Was This Post Helpful? 0
  • +
  • -

#10 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: help with INSERT INTO statement

Posted 26 September 2012 - 12:33 PM

Wrap password with [] or rename it in the database, it's being seen as a keyword.

Update logintable SET [password] = 'yourPW' WHERE username = 'yourUser'
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1