try specifying the size of the memory stream, are you also sure stringtobytearray is doing what it should?
Dim ms As New MemoryStream(obj, 0, obj.Length)
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
try this then, c# but i'm sure you can convert it to vb
ImageConverter imageConverter = new System.Drawing.ImageConverter();
Image image = imageConverter.ConvertFrom(obj) as Image;
if that doesn't work, i'm wondering if its an encoding issue
try swapping out your string to byte array with this
Public Shared Function StringToByteArray(intput As String) As Byte()
Dim encoding As New System.Text.ASCIIEncoding()
Return encoding.GetBytes(input)
End Function
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
try to save the byte array to a file rather than image first, and see if you can open that file up properly
'Get our byte array
obj = StringToByteArray(ImageString)
'Save to a file
Dim oFileStream As System.IO.FileStream
oFileStream = New System.IO.FileStream("image.jpg", System.IO.FileMode.Create)
oFileStream.Write(obj, 0, obj.Length)
oFileStream.Close()
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
i'm not sure what you are meaning
the actual value? of what?
and what are you wanting to use for testing?
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
why can't you just do an import into sql server without going code side?
also are you sure you mean a psv or csv?
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
opening it up wouldn't do anything, as long as you don't save it
have you tried to import inside management studio specifying the pipe, or doing something like this?
BULK INSERT MyTableName
FROM 'c:\mydata.psv'
WITH
(
FIELDTERMINATOR = '|',
ROWTERMINATOR = '\n'
)
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
the management tool you need for the import is just sql management studio or even run it through code
did you try the bulk insert?
escape format meaning?
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143
are you meaning all your double backslashes?
just run a replace on your escaped characters
Dim fileAsString As String = myString.Replace("\\", "\")
i think this is how with vb, more familiar with csharp
dickersonka
Veteran Poster
1,175 posts since Aug 2008
Reputation Points: 130
Solved Threads: 143