Results 1 to 13 of 13

Thread: Streaming

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    Streaming

    Have any of you used the ADODB Stream before? I'm trying to put a Memory Stream into a database and am having trouble with the syntax...

    Any help or example code you all could provide would be great.

    Thanks,

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  2. #2
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    What kind of database?
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    It's an Access Database. I've been using the Microsoft.Jet.OLEDB.4.0 provider...


    Thanks,

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  4. #4
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    I haven't used Access in a long time. Is there a datatype for storing large binary data? If there is, the memory stream has a ToArray method for converting it into a binary array.
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    Yes, you can store Long Binary Data in an OLE field in an Access Database...

    ToArray you say?

    I'll look into it. Thanks,

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    Ok... So I can convert the MemoryStream to a binary array. Now how do I get that binary array into the OLE field...

    I have tried many variations of the following, but none have worked so far...

    VB Code:
    1. Dim myADOStream As New ADODB.Stream
    2.  
    3.         ConnectToRecordset("SELECT * FROM myTable")
    4.         AddRecord()
    5.         SetVal("Name", Name)
    6.         myADOStream.Open()
    7.         myADOStream.Type = ADODB.StreamTypeEnum.adTypeBinary
    8.         myADOStream.Write(SerializeList(myArrayList).ToArray)
    9.         RS.Fields("Data").Value = myADOStream.Read()
    10.         Update()
    11.         Close()

    This code goes through all right, but when I check the database, there is NOTHING in the "Data" field of my recordset

    It should at least say somethingl like "Long Binay Data" or something like that... right?

    Thanks,

    squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  7. #7
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    Why are you using ADO and not ADO.NET?
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    LOL... Probably because I could program ADO with my eyes shut and half asleep (the latter is actually pretty common for me :P)

    Do you know of any good resources for programming with ADO.Net? Is it easier?

    Thanks,

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    Do you know of any way to do this with ADO.Net?

    Sq1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  10. #10
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    If it was SQL Server, it would be something like:

    Dim buffer() As Byte = memStrm.ToArray()

    ' Construct INSERT Command
    Dim sqlCommand as new sqlClient.SqlCommand
    Dim strSQl as String

    strSQL = "INSERT INTO MyTable (MyData) VALUES (@MyData)"

    sqlCommand.Parameters.Add("@MyData", SqlDbType.Image, buffer.Length).Value = buffer

    SQLConn.Open()

    sqlCommand.ExecuteNonQuery()

    SQLConn.Close()

    I haven't tried it with Access though. You probably have to use the OleDB stuff instead of the SQL Client stuff, and I think params are ? instead of @. But the code should be something similiar.
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    what does the @ symbol stand for?

    Sq1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  12. #12
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    In SQLClient, the @ is used to mark a parameter (that then has to be provided in the SQLCommand.Parameters collection). OleDB works a little bit different in that it uses ? instead of the @ParamName. I haven't really played with it so I'd suggest doing a search on the OLEDBCommand.Parameters
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  13. #13
    Hyperactive Member
    Join Date
    Jun 2004
    Location
    Utah, USA
    Posts
    353

    Re: Streaming

    Does anyone know how to retrieve a file saved in SQL Server. I know how to upload, but not how to download it to a place I choose(savefiledialog). Anyone know? Thanks!
    Brenda

    If it weren't for you guys, where would I be?

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