3 Replies - 3619 Views - Last Post: 07 June 2010 - 01:11 AM Rate Topic: -----

#1 krazzy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 01-May 08

how to store videos in database

Posted 03 June 2010 - 12:28 AM

i m making an window application in VB.NET 2005 , i want to know how can i store videos and images in database--pls tell me of using ORACLE 10g or SQL SERVER 2005 or My SQL
Is This A Good Question/Topic? 0
  • +

Replies To: how to store videos in database

#2 Frinavale  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 203
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: how to store videos in database

Posted 03 June 2010 - 01:07 PM

You should choose the database management system that you're going to be using first :)
Each database has their own "data type" for images etc.

For example: storing images into a MS SQL database would require you to create a column of type "image"; however in Oracle you would have to create the column as type "BLOB".

-Frinny
Was This Post Helpful? 2
  • +
  • -

#3 Charles:)  Icon User is offline

  • D.I.C Regular

Reputation: 132
  • View blog
  • Posts: 321
  • Joined: 26-November 09

Re: how to store videos in database

Posted 04 June 2010 - 04:17 AM

It's usually a bad idea - databases aren't designed to hold videos so you should store them on a file system if possible.

But if you must store in a database then one way is to read the video as a binary file and then store all of the bytes in a database.
Was This Post Helpful? 0
  • +
  • -

#4 ranbir  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 27
  • Joined: 04-June 10

Re: how to store videos in database

Posted 07 June 2010 - 01:11 AM

Try this code :

Private Sub video_insert()
        Dim SourceFilePath As String
        OpenFileDialog1.Filter = "MP3 files(*.mp3)|*.mp3|Video files(*.mpg)|*.mpg|Video Disc MPEG (*.dat)|*.dat|All Files(*.*)|*.*"
        OpenFileDialog1.Multiselect = False
        If OpenFileDialog1.ShowDialog() <> Windows.Forms.DialogResult.OK Then Exit Sub
        SourceFilePath = OpenFileDialog1.FileName
        Dim VideoName As String = SourceFilePath

        If VideoName <> "" Then
            Dim fls As IO.FileStream
            fls = New IO.FileStream(VideoName, FileMode.Open, FileAccess.Read)
            Dim blob(fls.Length) As Byte
            fls.Read(blob, 0, System.Convert.ToInt32(fls.Length))
            fls.Close()

            Dim conn As OracleConnection = New OracleConnection("yourConnectionString")
            Dim query = "insert into sampletable(videoField) values(video=:blobParameter)"
            conn.Open()
            Dim cmnd As OracleCommand
            Dim blobParameter = New OracleParameter()
            blobParameter.OracleType = OracleType.Blob
            blobParameter.ParameterName = "BlobParameter"
            blobParameter.Value = blob
            cmnd = New OracleCommand(query, conn)
            cmnd.Parameters.Add(blobParameter)
            cmnd.ExecuteNonQuery()
            cmnd.Dispose()
            conn.Close()
            conn.Dispose()
        End If
    End Sub


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1