Dear All.,
I want to read a column which has 2 blob format in the below code
I have 2 blob format in the same column as the following:
1- Colour picture start with 0000 WIDTH=480 HEIGHT=640
2- B&W (Black and white) picture start with FF B&W WIDTH=153 HEIGHT=208
I am using DB2 VER10.5 AND VS 2010, I get the below error when I try to read them
System.ArgumentException: Parameter is not valid.
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
at System.Drawing.Image.FromStream(Stream stream)
at PHOTOSMATCH.Form4.Button1_Click(Object sender, EventArgs e) in E:\PHOTOSMATCH\PHOTOSMATCH\Form4.vb:line 72
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
So, How can I solve the parameter error to be able to read both format?
Thanks for your co-operations.
I want to read a column which has 2 blob format in the below code
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If (OleDbConnection1.State And ConnectionState.Open) <> 0 Then
OleDbConnection1.Close()
End If
OleDbConnection1.ConnectionString = "Provider=IBMDADB2.DB2COPY1;Data Source=PORTLOB;Persist Security Info=True;Password=123456;User ID=Administrator;oledbreportislongforlongtypes=1;lobmaxcolumnsize=20480;longdatacompat=1;allowgetdatalobreaccess=1;"
'MaximumInlineLobSize=32; HexParserOption=Binary;
OleDbDataAdapter1.SelectCommand = OleDbSelectCommand1
OleDbSelectCommand1.CommandText = "SELECT P_IMAGE FROM PORTLOB WHERE ID=(" & Text1.Text & ") "
OleDbSelectCommand1.Connection = OleDbConnection1
DataSet11.PORT_IMAGE.Clear()
OleDbConnection1.Open()
Try
OleDbDataAdapter1.Fill(DataSet11, "PORT_IMAGE")
Dim c As Integer = DataSet11.Tables("PORT_IMAGE").Rows.Count
If c > 0 Then
Dim bytBLOBImage() As Byte = DataSet11.Tables("PORT_IMAGE").Rows(c - 1)("P_IMAGE")
Dim ms As MemoryStream = New MemoryStream(bytBLOBImage)
PictureBox1.Image = Image.FromStream(ms)
Else
MessageBox.Show("NO PHOTOS")
End If
Catch Ex As OleDb.OleDbException
MessageBox.Show(Ex.Message)
End Try
OleDbConnection1.Close()
End Sub
1- Colour picture start with 0000 WIDTH=480 HEIGHT=640
2- B&W (Black and white) picture start with FF B&W WIDTH=153 HEIGHT=208
I am using DB2 VER10.5 AND VS 2010, I get the below error when I try to read them
Quote:
System.ArgumentException: Parameter is not valid.
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
at System.Drawing.Image.FromStream(Stream stream)
at PHOTOSMATCH.Form4.Button1_Click(Object sender, EventArgs e) in E:\PHOTOSMATCH\PHOTOSMATCH\Form4.vb:line 72
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Thanks for your co-operations.