Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename and save images from SQLSERVER to folder on desktop

Status
Not open for further replies.

atruhoo

Programmer
Jan 8, 2003
131
US
Hey guys I seem to be having one of those days where the brain is on shutdown. What I am trying to do is trying to download images from our SQLSERVER DB, rename them and save them to a folder on the laptop to use when app is disconnected from server.

Currently they are brought back and stored as binary in an XML file which last time was around 635 MB (not my design, just addressing an isue) which caused problems when the XML file was being read into memory. I know I can save them down into a table on the laptop but trying to ensure that this can be done on any laptop/machine with or without SQLSERVER on it.

Any help leading me in the right direction would be helpful
 
Figured it out soon after posted....Figured post the fix in case someone else has one of those days.

Public Function GetExhibitTest() As Boolean
Dim fileName As String
Dim fileDescription As String
Dim oSDR As SafeDataReader
Dim oDasl As New DASL
Dim blob As [Byte]() = Nothing
Dim fileExt As String
Dim ft As FileStream = Nothing
Dim PartyExhibitId As Integer
Try

oSDR = oDasl.FetchSafeDataReader(oDasl.cMUST, "usp_Get_ExhibitsTest")
With oSDR
Do While .Read
blob = New [Byte](oSDR.GetBytes(1, CLng(0), Nothing, 0, Integer.MaxValue)) {}
oSDR.GetBytes(1, 0, blob, 0, blob.Length)
fileExt = RTrim(oSDR.GetString("FileExtension"))
fileDescription = CStr(.GetInt32("PartyExhibitID"))
fileName = "C:\Documents and Settings\atruhoo\Desktop\TEST\" + fileDescription + "."
ft = New FileStream(fileName + fileExt, FileMode.Create, FileAccess.Write)
ft.Write(blob, 0, blob.Length)

Loop
oSDR.Close()
ft.Close()
End With


Catch ex As Exception
Dim oLog As New Logger(ex, cMODNAME + "GetExhibitObject")
Throw ex

Finally
oSDR.Dispose()
oDasl.Dispose()
ft = Nothing
blob = Nothing

End Try
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top