|
-
Jul 9th, 2004, 01:54 PM
#1
Thread Starter
Frenzied Member
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?
-
Jul 9th, 2004, 02:10 PM
#2
Frenzied Member
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.
-
Jul 9th, 2004, 02:17 PM
#3
Thread Starter
Frenzied Member
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?
-
Jul 9th, 2004, 02:24 PM
#4
Frenzied Member
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.
-
Jul 9th, 2004, 02:32 PM
#5
Thread Starter
Frenzied Member
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?
-
Jul 9th, 2004, 02:55 PM
#6
Thread Starter
Frenzied Member
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:
Dim myADOStream As New ADODB.Stream
ConnectToRecordset("SELECT * FROM myTable")
AddRecord()
SetVal("Name", Name)
myADOStream.Open()
myADOStream.Type = ADODB.StreamTypeEnum.adTypeBinary
myADOStream.Write(SerializeList(myArrayList).ToArray)
RS.Fields("Data").Value = myADOStream.Read()
Update()
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?
-
Jul 9th, 2004, 03:18 PM
#7
Frenzied Member
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.
-
Jul 9th, 2004, 03:20 PM
#8
Thread Starter
Frenzied Member
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?
-
Jul 9th, 2004, 03:21 PM
#9
Thread Starter
Frenzied Member
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?
-
Jul 9th, 2004, 03:29 PM
#10
Frenzied Member
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.
-
Jul 9th, 2004, 03:45 PM
#11
Thread Starter
Frenzied Member
what does the @ symbol stand for?
Sq1
Now happily married and still crankin' away at the keyboard.  Life is grand for a coder, no?
-
Jul 9th, 2004, 03:48 PM
#12
Frenzied Member
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.
-
Dec 14th, 2004, 01:14 PM
#13
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|