Write binary data to database

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Muhs

    Write binary data to database

    Hi all..

    I have converted text document to blob(binary large objects) in an
    array binaryArray [], now the data needs to be saved in database table
    'Dokumet'

    The following code does not save the binary array in the database
    field 'Document'.. dont know whats wrong..
    im new to vb.net and datasets..

    kindly help me!




    Dim len As Integer

    Dim fs As FileStream = New FileStream(File Name,
    FileMode.OpenOr Create, FileAccess.Read )
    len = CInt(fs.Length) ' convert from long to type int
    Dim binaryArray() As Byte = New Byte(len - 1) {}
    fs.Read(binaryA rray, 0, len)
    fs.Close()


    '---- check code

    Dim name As String
    name = "af"

    Dim tdsDocumentObj As New tdsDocument.Dok umentDataTable

    Dim something As tdsDocument.Dok umentRow = Nothing

    something = tdsDocumentObj. NewDokumentRow

    something.Docum ent = (binaryArray)

    tdsDocumentObj. AcceptChanges()
  • Cor Ligthert[MVP]

    #2
    Re: Write binary data to database

    Hi Muhs,

    Are you sure you will not get trouble by using len as a dataname, it is
    strange that it does not give errors.


    Here the link to what you ask about the document to a database.


    Cor



    "Muhs" <shumyl21@gmail .comwrote in message
    news:8acb7a88-a785-4e0c-9568-da1fdfa10138@v1 3g2000pro.googl egroups.com...
    Hi all..
    >
    I have converted text document to blob(binary large objects) in an
    array binaryArray [], now the data needs to be saved in database table
    'Dokumet'
    >
    The following code does not save the binary array in the database
    field 'Document'.. dont know whats wrong..
    im new to vb.net and datasets..
    >
    kindly help me!
    >
    >
    >
    >
    Dim len As Integer
    >
    Dim fs As FileStream = New FileStream(File Name,
    FileMode.OpenOr Create, FileAccess.Read )
    len = CInt(fs.Length) ' convert from long to type int
    Dim binaryArray() As Byte = New Byte(len - 1) {}
    fs.Read(binaryA rray, 0, len)
    fs.Close()
    >
    >
    '---- check code
    >
    Dim name As String
    name = "af"
    >
    Dim tdsDocumentObj As New tdsDocument.Dok umentDataTable
    >
    Dim something As tdsDocument.Dok umentRow = Nothing
    >
    something = tdsDocumentObj. NewDokumentRow
    >
    something.Docum ent = (binaryArray)
    >
    tdsDocumentObj. AcceptChanges()

    Comment

    Working...