CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005
    Posts
    61

    General Database questions

    I'm using Visual Studio 2008 version 3.5. I downloaded SQL server 2005 Express but I've got some questions.

    When I add a service based database, how do I add an image to the image data type?

    Also, how do I add an MP3 to the Binary data type?

    I used this video to add the service based database.

    http://www.youtube.com/watch?v=X9bP1fTihjw

  2. #2
    Join Date
    Nov 2006
    Posts
    357

    Re: General Database questions

    Never used a service based database but im assuming it is just a normal database with some wrapping on it or something...

    Usually when you store binarydata it gets put into a BLOB type column (although ive never done that), so i think you would need to load up your MP3 or Image, then get a stream on it, then write that streams bytes into your new row...

    Im sure you have a very valid reason for storing MP3s and Images as BLOBs within a database, but have you thought about just making a filename reference in your DB, so you would instead of having a binary chunk of data for each file that could range from 10kb to 10mb have a string column which would contain the filename of your file.

    Your current flow im assuming would be something like:

    Code:
    // Load MP3 file
    // Read MP3 data
    // Save MP3 to DB
    
    // Read MP3 from DB
    // Read MP3 data
    // Play MP3
    The first chunk being you saving it to the DB in the first place, then the 2nd chunk being you reading it back out for use. However if you were to use the filename based method you could do:

    Code:
    // Get MP3 Filename
    // Save MP3 Filename to DB
    
    // Read MP3 Filename from DB
    // Load MP3 File
    // Read MP3 Data
    // Play MP3
    That way your DB is only storing a few characters for your filename and you then can have as many hard disk drives as you want storing your music, rather than having one MASSIVE database...

    Again im not sure what you are trying to do, as BLOB types are perfectly valid in certain scenarios, so not sure if any of my waffling will help...

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

Featured