Hi Cor,
Yes, thank you, it really did!
I´ve been brooding on this problem for some time now.
Thanks to your hints I came up with the following code in C#,
which works OK for me. But I´m actually not using Binding ...
I have a small MS Access DB called BMprov.mdb for trial.
It contains only one table called PicTest, and this table
contains only three columns:
PicNo (numeric runing number)
Name (character string)
PicDraw (bitmap picture, an ActiveX-object derived from a jpg-file in the MS
Access environment).
Here is the essential code:
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Data;
using System.Data.Ole Db;
using System.IO;
.....
public void runPicture(stri ng picNo)
{
// ICa 2005-06-03 20:38
Cursor tmp = this.Cursor;
this.Cursor = Cursors.WaitCur sor;
try
{
OleDbConnection picC = new OleDbConnection ();
picC.Connection String = "Provider=Micro soft.JET.OLEDB. 4.0;" + @"data
source = C:\Waterials\Da tabas\BMprov.md b";
picC.Open();
string sqlString = "SELECT * FROM PicTest WHERE PicNo = " + picNo;
OleDbDataAdapte r picA = new OleDbDataAdapte r (sqlString, picC);
OleDbCommandBui lder picB = new OleDbCommandBui lder(picA);
DataSet picD = new DataSet();
picA.Fill(picD, "PicTest");
DataTable picT = picD.Tables["PicTest"];
txPicNo.Text = picT.Rows[0]["PicNo"].ToString();
txName.Text = picT.Rows[0]["Name"].ToString();
Byte[] draw = (Byte[]) picT.Rows[0]["PicDraw"];
MemoryStream ms = new MemoryStream(dr aw, 78, draw.Length -78);
pbDrawing.Image = Image.FromStrea m(ms);
ms.Close();
}
catch (Exception ex)
{
MessageBox.Show ("Fel vid framtagning av bild: " + ex.Message,
"Bild-fel", MessageBoxButto ns.OK,
MessageBoxIcon. Error);
}
this.Cursor = tmp;
}
It sure took me some good time to figure all this out ...
Best regards
/Jingo
"Cor Ligthert" wrote:
Paul,
First of all do I when I have this kind of problems create some extra steps
in my code.
Now it is nice connected however hard to debug and even more difficult to
show to somebody else.
Secondly, I don't see the reason for the binding in this. You use a "next
button".
Here a piece from a program from me, not a sample, so I cannot show it
complete because that will be to much.
\\\
Private Sub btnNext_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles btnNext.Click
If number < dsFototabel.Tab les(0).Rows.Cou nt - 1 Then
number += 1
setPicture()
End If
End Sub
///
And then there is in fact nothing more than
\\\
arrPicture = CType(dsFototab el.Tables(0).Ro ws(number)("thu mb"), Byte())
ms = New MemoryStream(ar rPicture)
picCurrent.Imag e = Image.FromStrea m(ms)
///
However it can as well be that you are using OLE pictures, than you have to
set (hopefully because there are more formats in that)
\\\
Dim ms1 As New System.IO.Memor yStream(arrPict ure, 78, arrPicture.Leng th -
78)
///
I hope this helps a little bit?
Cor