Results 1 to 5 of 5

Thread: 2 Database Questions

  1. #1

    Thread Starter
    Hyperactive Member Stiletto's Avatar
    Join Date
    Aug 2002
    Location
    Jerusalem, Israel
    Posts
    287

    2 Database Questions

    1. How can I clear a recordset, Deleting all fields from the recordset?
    2. How can i check if a field is exist?
    Tnx

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    are you wanting to delete the values contained in the fields?
    or delete the fields from the tables?

    what database system are you using?

    are you doing this in VB, C++, ASP?
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3

    Thread Starter
    Hyperactive Member Stiletto's Avatar
    Join Date
    Aug 2002
    Location
    Jerusalem, Israel
    Posts
    287
    i'm using VB and Access
    I want to delete Values.

    What about the second question?

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    1) Execute the following sql
    Delete * from tablename

    2)
    Open a recordset with
    Select * from Tablename
    Using error handling (on error resume next) and use the following lines of vbcode:
    VB Code:
    1. Dim strTester as string
    2.  
    3.      on error resume next
    4.      strtester=rst("fieldname").name
    5.      if err.number = 0 then
    6.        'field exists
    7.      else
    8.        err.clear
    9.        'field doesn't exist
    10.      endif
    Tablename is the name of the table
    fieldname is the fieldname
    Code above assuems rst is the recordset (put the dim in the first few lines and the rest of the code where you need it)


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  5. #5
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    I don't think you need the * in the DELETE statement...
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

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