D
Deepankar
Hi,
I was trying to change an example for SQL Server to work with Access
db to insert image data. I have everything working except getting the
OleDbParameter type for the image column.
The table in access is :
img (
id number ,
name Text,
img number [Byte]
);
code :
===========
//....
byte[] photo = GetPhoto(photoFilePath);
OleDbConnection Conn = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; User Id=;Data
Source=C:\\temp\\testdb.mdb");
OleDbCommand addJpg = new OleDbCommand("update img set img =
@Photo where id = @id", Conn);
OleDbDataAdapter MyDataAdapter = new OleDbDataAdapter();
MyDataAdapter.InsertCommand = addJpg ;
OleDbParameter id = new OleDbParameter ("@id", OleDbType.Integer)
;
id.Value = 1;
OleDbParameter ph = new OleDbParameter ("@Photo",
OleDbType.VarBinary, photo.Length) ;
ph.Value = photo;
MyDataAdapter.InsertCommand .Parameters.Add(ph);
MyDataAdapter.InsertCommand .Parameters.Add(id);
// connect
Conn.Open();
// insert
addJpg.ExecuteNonQuery();
Conn.Close();
//........
Any pointers...
Thanx in Advance
DN
I was trying to change an example for SQL Server to work with Access
db to insert image data. I have everything working except getting the
OleDbParameter type for the image column.
The table in access is :
img (
id number ,
name Text,
img number [Byte]
);
code :
===========
//....
byte[] photo = GetPhoto(photoFilePath);
OleDbConnection Conn = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; User Id=;Data
Source=C:\\temp\\testdb.mdb");
OleDbCommand addJpg = new OleDbCommand("update img set img =
@Photo where id = @id", Conn);
OleDbDataAdapter MyDataAdapter = new OleDbDataAdapter();
MyDataAdapter.InsertCommand = addJpg ;
OleDbParameter id = new OleDbParameter ("@id", OleDbType.Integer)
;
id.Value = 1;
OleDbParameter ph = new OleDbParameter ("@Photo",
OleDbType.VarBinary, photo.Length) ;
ph.Value = photo;
MyDataAdapter.InsertCommand .Parameters.Add(ph);
MyDataAdapter.InsertCommand .Parameters.Add(id);
// connect
Conn.Open();
// insert
addJpg.ExecuteNonQuery();
Conn.Close();
//........
Any pointers...
Thanx in Advance
DN