Hey There, <BR><BR>Can anyone tell me how to get binary data stored in an SQL-Server into a Stream object or a physical file in VB.net.<BR><BR>I have created a system that allows the user to upload any kind of file to the database. The file&#039;s binary data is stored in a BLOB (image) field in the SQL-Server. I can output these data to a browser showing the image (if gif/jpg) or make it open the acociated program (msword, acrobat). <BR><BR>Since I need to do a bit of image editing (on valid images) using the graphics class, I would like to get the filedata out as a physical file (or stream), but this gives me troubles. I have tried to use different combinations of streamobjects, but cannot figure out how to get the data from the sqlDataReader object to the Stream object. <BR><BR>Here&#039;s the code i use (can you see whats wrong?): <BR><BR>Sub Create_File() <BR>Dim fs As FileStream <BR>Dim bw As BinaryWriter <BR>Dim buffersize As Int32 = 100 <BR>Dim outbyte As Byte() <BR>ReDim outbyte(buffersize) <BR>Dim retval As Long <BR>Dim pubid As String <BR>Dim startindex As Long <BR><BR>Dim SQLconn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("a dminSQLconn")) <BR>Dim logoCMD As New SqlCommand("SELECT ID, FileData FROM FileVersions", SQLconn) <BR>&#039; FileData is an IMAGE datatype in the SQL-Server. <BR>SQLconn.Open() <BR>Dim dbread As SqlDataReader = logoCMD.ExecuteReader(CommandBehavior.SequentialAc cess) <BR>While dbread.Read <BR><BR>pubid = dbread.GetInt32(0).ToString <BR>fs = New FileStream("c:inetpubwwwrootatdotnetadminlogo" + pubid + ".bmp", FileMode.OpenOrCreate, FileAccess.Write) <BR>bw = New BinaryWriter(fs) <BR>startindex = 0 <BR>retval = dbread.GetBytes(1, startindex, outbyte, 0, buffersize) <BR><BR>While retval = buffersize <BR>bw.Write(outbyte) <BR>bw.Flush() <BR>startindex += buffersize <BR>retval = dbread.GetBytes(1, startindex, outbyte, 0, buffersize) <BR>End While <BR><BR>bw.Write(outbyte) <BR>bw.Flush() <BR><BR>bw.Close() <BR>fs.Close() <BR><BR>End While <BR><BR>dbread.Close() <BR>SQLconn.Close() <BR><BR>End Sub <BR>