Results 1 to 4 of 4

Thread: [2005] delect and update statement in dataset

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    [2005] delect and update statement in dataset

    if I select the specific rows and want to delete, what is the code?
    I have try the code
    Code:
    delect from table;
    but it delete all of my rows

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] delect and update statement in dataset

    This is not a VB.NET question. SQL questions belong in the Database Development forum.

    You need to use a WHERE clause to specify which records you want to delect (sic). If you want to delete a specific record by ID it would be:
    Code:
    DELETE FROM MyTable WHERE ID = @ID
    If you want to delete all records from before a specific date it would be:
    Code:
    DELETE FROM MyTable WHERE [Date] < @Date
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Re: [2005] delect and update statement in dataset

    okay, next time I will post the sql question to Database Development forum
    do the code add to the delete button?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] delect and update statement in dataset

    What you posted and what I posted is SQL code, not VB code. If you want to execute SQL statements in VB then you use ADO.NET. If you want to do something when the user clicks a Button you handle its Click event. You need to create a Click event handler for your button and use ADO.NET to execute that SQL. Follow the Data Access link in my signature for some examples of using ADO.NET in VB.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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