Click here to Skip to main content
15,895,142 members
Home / Discussions / Database
   

Database

 
Generalprogress Pin
Yulianto.6-Dec-04 15:45
Yulianto.6-Dec-04 15:45 
GeneralRe: progress Pin
Dave Kreskowiak10-Dec-04 9:50
mveDave Kreskowiak10-Dec-04 9:50 
GeneralInvoke oracle job remotley Pin
RobNicolson6-Dec-04 4:44
RobNicolson6-Dec-04 4:44 
QuestionBLOBs: How to insert/store and get/retrieve an object? Pin
Rafferty Uy5-Dec-04 13:58
Rafferty Uy5-Dec-04 13:58 
AnswerRe: BLOBs: How to insert/store an object? Pin
Steve S6-Dec-04 1:32
Steve S6-Dec-04 1:32 
GeneralRe: BLOBs: How to insert/store an object? Pin
Rafferty Uy6-Dec-04 13:18
Rafferty Uy6-Dec-04 13:18 
GeneralRe: BLOBs: How to insert/store an object? Pin
Steve S7-Dec-04 1:30
Steve S7-Dec-04 1:30 
AnswerRe: BLOBs: How to insert/store and get/retrieve an object? Pin
Rafferty Uy8-Dec-04 17:01
Rafferty Uy8-Dec-04 17:01 
I'll try to summarize what i did for inserting and for retrieving the BLOBs in a pseudo-code level...

object obj1;<br />
object obj2;<br />
object obj3;<br />
<br />
InsertData()<br />
{<br />
  MemoryStream stream = new MemoryStream();<br />
  BinaryFormatter formatter = new BinaryFormatter();<br />
<br />
  Hashtable ht = new Hashtable();<br />
  ht.Add( "Object1", obj1 );<br />
  ht.Add( "Object2", obj2 );<br />
  ht.Add( "Object3", obj3 );<br />
<br />
  formatter.Serialize( stream, ht );<br />
<br />
  // Convert the Hashtable into bytes.<br />
  int iStreamLength = Convert.ToInt32(stream.Length);<br />
  byte[] byteBackup = new byte[iStreamLength];<br />
  stream.Read( byteBackup, 0, iStreamLength );<br />
  stream.Close();<br />
<br />
  SqlConnection conn = new SqlConnection( strConnectionString );<br />
  SqlCommand cmd = new SqlCommand( "ins_BackupData", conn );<br />
  cmd.CommandType = CommandType.StoredProcedure;<br />
  cmd.Parameters.Add( "@Name", "ObjectsBackup" );<br />
  cmd.Parameters.Add( "@Data", byteBackup );<br />
<br />
  cmd.ExecuteNonQuery();<br />
}<br />
<br />
RetrieveData()<br />
{<br />
  SqlConnection conn = new SqlConnection( strConnectionString );<br />
  SqlCommand cmd = new SqlCommand( "get_BackupData", conn );<br />
  cmd.CommandType = CommandType.StoredProcedure;<br />
  cmd.Parameters.Add( "@Name", "ObjectsBackup" );<br />
<br />
  conn.Open();<br />
<br />
  object obj = cmd.ExecuteScalar();<br />
<br />
  if( obj != null )<br />
  {<br />
    byte[] byteBackup = (byte[])obj;<br />
    MemoryStream stream = new MemoryStream(byteBackup);<br />
    BinaryFormatter formatter = new BinaryFormatter();<br />
<br />
    Hashtable ht = (Hashtable)formatter.Deserialize( stream );<br />
    obj1 = ht["Object1"];<br />
    obj2 = ht["Object2"];<br />
    obj3 = ht["Object3"];<br />
<br />
    stream.Close();<br />
  }<br />
}


But in retrieving the data I'm getting this error, so clearly there's something wrong. I wonder if it's with the insertion or retrieval or both.

ERROR:
Binary stream does not contain a valid BinaryHeader, 0 possible causes, invalid stream or object version change between serialization and deserialization.

Any ideas? did I deserialize this incorrectly?
GeneralADO .NET and Excel... :( :( HELP!! Pin
fadee4-Dec-04 10:15
fadee4-Dec-04 10:15 
GeneralString array to Oracle procedure from VB.Net Pin
Santhimurthy3-Dec-04 22:05
Santhimurthy3-Dec-04 22:05 
QuestionCan anyone help me with this one? Pin
Suresh Prasad3-Dec-04 10:40
Suresh Prasad3-Dec-04 10:40 
AnswerRe: Can anyone help me with this one? Pin
Mike Ellison3-Dec-04 11:13
Mike Ellison3-Dec-04 11:13 
GeneralRe: Can anyone help me with this one? Pin
Suresh Prasad3-Dec-04 11:29
Suresh Prasad3-Dec-04 11:29 
GeneralRe: Can anyone help me with this one? Pin
Mike Ellison3-Dec-04 11:48
Mike Ellison3-Dec-04 11:48 
GeneralRe: Can anyone help me with this one? Pin
Suresh Prasad3-Dec-04 11:57
Suresh Prasad3-Dec-04 11:57 
GeneralUploading Large numbers of records Pin
mjackson113-Dec-04 8:07
mjackson113-Dec-04 8:07 
GeneralRe: Uploading Large numbers of records Pin
Alex Korchemniy4-Dec-04 16:56
Alex Korchemniy4-Dec-04 16:56 
GeneralRe: Uploading Large numbers of records Pin
mjackson118-Dec-04 9:42
mjackson118-Dec-04 9:42 
GeneralADO.NET columns are magic numbers.. Pin
giorgos_gr3-Dec-04 5:09
giorgos_gr3-Dec-04 5:09 
GeneralSQL Tree Hierarchy Problem Pin
Dirk Kok2-Dec-04 22:24
sussDirk Kok2-Dec-04 22:24 
GeneralRe: SQL Tree Hierarchy Problem Pin
Michael Potter3-Dec-04 4:34
Michael Potter3-Dec-04 4:34 
GeneralRe: SQL Tree Hierarchy Problem Pin
Chris Meech3-Dec-04 6:44
Chris Meech3-Dec-04 6:44 
GeneralStored Proc and SqlDataAdapter Pin
ccosser2-Dec-04 22:03
ccosser2-Dec-04 22:03 
GeneralAttaching a database to MSDE Pin
mattie202-Dec-04 20:31
mattie202-Dec-04 20:31 
GeneralNested Transaction with SQL Server Pin
Wouter van Eck2-Dec-04 5:21
Wouter van Eck2-Dec-04 5:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.