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
Printable View
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
What kind of database?
It's an Access Database. I've been using the Microsoft.Jet.OLEDB.4.0 provider...
Thanks,
Squirrelly1
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.
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
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
Why are you using ADO and not ADO.NET?
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
Do you know of any way to do this with ADO.Net?
Sq1
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.
what does the @ symbol stand for?
Sq1
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
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!