1 Replies - 1348 Views - Last Post: 11 December 2013 - 10:26 PM Rate Topic: -----

#1 raelkun00  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 69
  • Joined: 01-October 12

Update database not working

Posted 09 December 2013 - 07:39 PM

My insert and delete is working but I don't know my Update is not working.There is no error.


Try
            objCon.con.Open()
   
            Dim cmd As New OleDbCommand("Update tbl_Test set stud_fn=@firstname where stud_id=@studentid", objCon.con)
            cmd.Parameters.AddWithValue("@firstname", txtFirstname.Text)
            cmd.Parameters.AddWithValue("@studentid", txtStudentID.Text)
            cmd.ExecuteNonQuery()
            ' Response.Redirect("Default.aspx", False)
            objCon.con.Close()

        Catch ex As Exception
            MsgBox(ex.ToString)

        End Try



Is This A Good Question/Topic? 0
  • +

Replies To: Update database not working

#2 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,505
  • Joined: 16-March 11

Re: Update database not working

Posted 11 December 2013 - 10:26 PM

cmd.Parameters.AddWithValue("@firstname", txtFirstname.Text)
cmd.Parameters.AddWithValue("@studentid", txtStudentID.Text)



Take the @ character out of the method. Leave it at firstname and studentid and then use the @ character in your oledbcommand.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1