Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Encounter problem when I am delete a record

Encounter problem when I am delete a record

Scheduled Pinned Locked Moved Visual Basic
databasehelpsales
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jackwongcw
    wrote on last edited by
    #1

    Dear ALL, I have encounter problem when I deleting a record in my program. Error msg as follow: OleDbException was unhandled. No value given for one or more required parameters. I think I have declare the correct statement but it still prompt me... My code as follow: Public Sub delRec(ByVal column As String, ByVal table As String, ByVal value As String) 'create connection instance with connection string Dim myConnection As New OleDbConnection(ConnString) 'sql delete query Dim query As String If table = "SALPASS" Then query = "DELETE FROM " & table & " where " + column + " = " + value Else query = "DELETE FROM " & table & " where " & column & " = " & value End If 'create sql command instance with the delete query Dim myCommand As New OleDbCommand(query, myConnection) 'open database connection myConnection.Open() 'execute sql delete command found in query string myCommand.ExecuteNonQuery() 'Close the connection myConnection.Close() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If GroupBox1.Text = "Sales" Then If TextBox1.Text = "" Then 'display error message box MsgBox("Error!" + vbCrLf + vbCrLf + "Please select User Id to delete", MsgBoxStyle.Exclamation, "Deletion Error") Else 'deletes record from database delRec("USER_ID", "SALPASS", TextBox1.Text) lblLabel.Text = "Record Deleted" 'refresh table getsaltable() End If end sub I just want to delete the user id and password. Please advise. Thanks Jack:confused: Jack

    R S 2 Replies Last reply
    0
    • J jackwongcw

      Dear ALL, I have encounter problem when I deleting a record in my program. Error msg as follow: OleDbException was unhandled. No value given for one or more required parameters. I think I have declare the correct statement but it still prompt me... My code as follow: Public Sub delRec(ByVal column As String, ByVal table As String, ByVal value As String) 'create connection instance with connection string Dim myConnection As New OleDbConnection(ConnString) 'sql delete query Dim query As String If table = "SALPASS" Then query = "DELETE FROM " & table & " where " + column + " = " + value Else query = "DELETE FROM " & table & " where " & column & " = " & value End If 'create sql command instance with the delete query Dim myCommand As New OleDbCommand(query, myConnection) 'open database connection myConnection.Open() 'execute sql delete command found in query string myCommand.ExecuteNonQuery() 'Close the connection myConnection.Close() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If GroupBox1.Text = "Sales" Then If TextBox1.Text = "" Then 'display error message box MsgBox("Error!" + vbCrLf + vbCrLf + "Please select User Id to delete", MsgBoxStyle.Exclamation, "Deletion Error") Else 'deletes record from database delRec("USER_ID", "SALPASS", TextBox1.Text) lblLabel.Text = "Record Deleted" 'refresh table getsaltable() End If end sub I just want to delete the user id and password. Please advise. Thanks Jack:confused: Jack

      R Offline
      R Offline
      Rizwan Bashir
      wrote on last edited by
      #2

      Do one thing. the query you build in the function. Copy that Query and run that directly in the SQL Query analyzer or what ever the database you are using. this will clear you that the query is fine. Also check on which line it creates the problem ?

      1 Reply Last reply
      0
      • J jackwongcw

        Dear ALL, I have encounter problem when I deleting a record in my program. Error msg as follow: OleDbException was unhandled. No value given for one or more required parameters. I think I have declare the correct statement but it still prompt me... My code as follow: Public Sub delRec(ByVal column As String, ByVal table As String, ByVal value As String) 'create connection instance with connection string Dim myConnection As New OleDbConnection(ConnString) 'sql delete query Dim query As String If table = "SALPASS" Then query = "DELETE FROM " & table & " where " + column + " = " + value Else query = "DELETE FROM " & table & " where " & column & " = " & value End If 'create sql command instance with the delete query Dim myCommand As New OleDbCommand(query, myConnection) 'open database connection myConnection.Open() 'execute sql delete command found in query string myCommand.ExecuteNonQuery() 'Close the connection myConnection.Close() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If GroupBox1.Text = "Sales" Then If TextBox1.Text = "" Then 'display error message box MsgBox("Error!" + vbCrLf + vbCrLf + "Please select User Id to delete", MsgBoxStyle.Exclamation, "Deletion Error") Else 'deletes record from database delRec("USER_ID", "SALPASS", TextBox1.Text) lblLabel.Text = "Record Deleted" 'refresh table getsaltable() End If end sub I just want to delete the user id and password. Please advise. Thanks Jack:confused: Jack

        S Offline
        S Offline
        swami_v3
        wrote on last edited by
        #3

        ur query i think is somewhat wrong. It should be query="DELETE FROM '"& table &"' where '" + column + "' = '" + value+"' format should be =" from '"++"' " all runtime values should be entered inthis format '"++"' if + sign doesn't work try &

        J 1 Reply Last reply
        0
        • S swami_v3

          ur query i think is somewhat wrong. It should be query="DELETE FROM '"& table &"' where '" + column + "' = '" + value+"' format should be =" from '"++"' " all runtime values should be entered inthis format '"++"' if + sign doesn't work try &

          J Offline
          J Offline
          jackwongcw
          wrote on last edited by
          #4

          :)Thanks Will try on that jack

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups