Results 1 to 5 of 5

Thread: [RESOLVED] [2005] General Database Question

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,051

    Resolved [RESOLVED] [2005] General Database Question

    Completely new to databases:

    In general...

    If I save an object to a database how would I query to obtain the properties of the object.
    Would I query to return the object and then get the properties via client code; or, is there a way for the database itself to return the properties even if the properties are not stored individually within the database.
    Are there any database procedures etc that could return the individual property values given just an object?

    Logically, it seems to me that you'd need to obtain the object and then the client code would work with the object.

    Thanks

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

    Re: [2005] General Database Question

    A database doesn't save objects. It saves values. Think of a database table as a class and each record in the table as an instance of that class. If you have an object in VB that you want to persist to a database then you would create a DataRow and copy each property value to a field. When you then save the DataTable's changes to the database that row will be saved, along with all its field values. When you query the database you can then recreate your object by assigning each record field to the appropriate property. A database cannot tell you anything about an object that you didn't save to that database. It has no magic.
    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
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,051

    Re: [2005] General Database Question

    Thanks jm.

    (But I still prefer magic).
    Last edited by FourBlades; Nov 24th, 2007 at 10:56 PM.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,051

    Re: [RESOLVED] [2005] General Database Question

    Let me resurrect this post for a bit..

    I hate to ask this question, but I just have to...

    Why don't databases store objects?

  5. #5
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    Re: [RESOLVED] [2005] General Database Question

    They can store bitmaps.. Access 2007 can store any picture in its original format.. does that count? Theoretically, you could store any object as a series of 0's and 1's if you had a binary reader to retrieve it.

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