Results 1 to 3 of 3

Thread: Delete Table Rows From Database

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2010
    Posts
    58

    Delete Table Rows From Database

    I have a table that has lots of entries. I want to delete all the entries.

    I tried this but it doesn't work.
    Code:
    Using connection As New SqlConnection(Form1.ConnectionString)
                            Using adapter As New SqlDataAdapter("SELECT EmployeeID, EmployeeID, Rate FROM EmployeeRate", _
                                                              connection)
    
                                Dim delete As New SqlCommand("DELETE FROM EmployeeRate", _
                                                           connection)
                                adapter.InsertCommand = delete
                            End Using
                        End Using

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Delete Table Rows From Database

    There is no need for a DataAdapter, or an InsertCommand... you just need to create the Command object, and then execute it.

  3. #3
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Delete Table Rows From Database

    Of course the SQL statement will delete all rows from the EmployeeRate table is that the desired effect?
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width