2 Replies - 497 Views - Last Post: 02 October 2011 - 07:45 PM Rate Topic: -----

#1 sanoshiy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-October 11

i need help on deleting record in ms access database using vb2008

Posted 01 October 2011 - 08:20 PM

hi! i'm currently working on a payroll system using vb2008 and deleting a record is my only problem. can you guys help me?

what happens is i have a weekly salary table and once a week an administrator computes the salaries and it will be saved there, i want the delete code to delete the already saved record with the same Emp_ID as what i'm trying to save. my problem is i don't think the code i put deletes the record because it will still tell me that there is already an Emp_ID the same with what i'm trying to save..

so far this is my code..

 Dim cnn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source = C:\Users\Florie\Documents\Visual Studio 2008\Projects\Payroll System\Payroll System\obj\x86\Debug\Payroll_MaryRoseAn.accdb")
        Dim cmd As New OleDbCommand

        cmd.Connection = cnn
        cmd.CommandType = CommandType.Text
        cmd.CommandText = "DELETE * FROM Salary Where [Emp_ID]=" & Trim(Emp_IDTextBox.Text) & ""
        Using cnn
            cnn.Open()
            cmd.ExecuteNonQuery()
        End Using


pls. help..

This post has been edited by sanoshiy: 01 October 2011 - 08:21 PM


Is This A Good Question/Topic? 0
  • +

Replies To: i need help on deleting record in ms access database using vb2008

#2 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1752
  • View blog
  • Posts: 4,409
  • Joined: 14-March 10

Re: i need help on deleting record in ms access database using vb2008

Posted 01 October 2011 - 08:26 PM

Isnt Emp_ID varchar? missing single quotes...

Also there is a problem from the one who designed that database, because it cant be to have a primary to the table where we need to post more than once(problem with design-database design)
Was This Post Helpful? 0
  • +
  • -

#3 sanoshiy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-October 11

Re: i need help on deleting record in ms access database using vb2008

Posted 02 October 2011 - 07:45 PM

i did not put a single quote because the emp_ID is a number not a text..i thought singke quote is only for text,

is it better if i change the type of emp_id to text in the database?


also, i'm using the delete code so that i will avoid duplication because the emp_ID is a primary key that's why i try to delete it first before saving a new one with a different informatin but same emp_Id as what i deleted.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1