Results 1 to 7 of 7

Thread: [RESOLVED] How to delete a record off of a database?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    148

    Resolved [RESOLVED] How to delete a record off of a database?

    I'm using the data control to work with a database on a program I have. The record I am using is "tempdata". How do I delete, or clear all the data in the "tempdata" ? I'm doing an MDB MS Access database.

  2. #2
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Philippines
    Posts
    468

    Re: How to delete a record off of a database?

    data1.recordsource="delete * from tempdata"
    data1.refresh

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    148

    Re: How to delete a record off of a database?

    I get a runtime error 3219
    Invalid operation

    On the Data1.Refresh

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    148

    Re: How to delete a record off of a database?

    And, the information still seems to be there.

  5. #5
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Philippines
    Posts
    468

    Re: How to delete a record off of a database?

    oops sorry datacontrol does not support that procedure

    msdn:
    DAO
    DAO, or Data Access Objects, has a place in the heart of all programmers who began to develop database applications with Visual Basic 3. DAO is an object-oriented interface to Microsoft Jet, the engine that powers Access. Developers can design an MDB database using Access and then use DAO from a Visual Basic application to open the database, add and retrieve records, and manage transactions. The best thing about DAO is that it doesn't limit you to Jet databases because you can directly open any database for which an ODBC driver exists. Or you can use Jet attached tables, which are virtual tables that appear to belong to an MDB database but actually retrieve and store data in other ODBC sources.

    Even if you can use DAO to access non-Jet sources, you can clearly see that it was devised with Access databases in mind. For example, even if your application doesn't use MDB databases, you still have to load the entire Jet engine DLL in memory. (And you also have to distribute it to your users). Even worse, DAO doesn't expose many of the capabilities that you could use if working directly with ODBC API functions. For example, you can't perform asynchronous queries or connections using DAO, nor can you work with multiple result sets.

    Visual Basic 3 also contained the first release of the Data control. This control lets you bind one or more controls on a form to a data source and offers buttons for navigating through the records of the database table you've connected to. At first, it seems that the Data control is a great tool because it lets you quickly create effective user interfaces to work with your data. After some testing, however, developers tend to abandon the Data control because its many limitations are difficult to overcome. Apart from performance considerations, the Data control has one serious disadvantage: It ties your front-end applications to the data in the back-end database. If you later want to access data in another database, you have to revise all the forms in your application. If you want to add complex validation rules to database fields, you must add code in every single module of the program. These (and other problems) are the typical defects of a 2-tier architecture, which in fact is being abandoned in favor of 3-tier (or n-tier) architectures, where one or more intermediate layers between the application and the database provide services such as data validation, business rules, workload balance, and security. Alas, if you want to embrace the n-tier philosophy, you should forget about the Data control.

    Visual Basic 4 included the improved DAO 3.0 version, which features a special DLL that allows programmers who work with 32-bit technology to access 16-bit databases. Visual Basic 5 programmers can use DAO 3.5. In the Visual Basic 6 package, you'll find DAO 3.51, which is substantially similar to the previous one. This suggests that Microsoft doesn't plan to improve DAO further, even though version 4 has been announced for Microsoft Office 2000.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    148

    Re: How to delete a record off of a database?

    so, it's not possible? What should I switch to so that it is possible?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    148

    Re: How to delete a record off of a database?

    I figured it out incase anyone else is interested in the solution

    Data1.RecordSource = "tempdata"
    Data1.Refresh

    While Not Data1.Recordset.EOF
    Data1.Recordset.Delete
    Data1.Recordset.MoveNext
    Wend

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