delphi7 + ado: Jet vs ODBC
From: Zinetz Victor (mail_at_zinetz.info)
Date: 03/25/05
- Next message: Richard Caruana: "How to add results to ADOQuery and DBGrid for browsing"
- Previous message: ercan: "Re: create access table with ado sql (cannot change table properties)"
- Next in thread: Brian Bushay TeamB: "Re: delphi7 + ado: Jet vs ODBC"
- Reply: Brian Bushay TeamB: "Re: delphi7 + ado: Jet vs ODBC"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 25 Mar 2005 11:32:13 +0200
Hi
I have trouble: i made simple table (in access mdb) and try to save some
info + images:
///////// some code
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////
cmd.CommandText := 'insert into my_table (data_field, image_field) values
(:data_field, :image_field)';
cmd.Parameters [0].Value := DateTimeToStr (now); // for testing
// try to add image - stupid example only for testing
bmp := TBitmap.Create;
bmp.Width := 96; bmp.Height := 96;
bmp.Canvas.TextOut (2, 2, 'test string');
// to save database size store in jpeg:
ms := TMemoryStream.Create;
try
jpg := TJPEGImage.Create;
try
jpg.Assign (bmp);
jpg.SaveToStream (ms);
ms.Position := 0;
cmd.Parameters [1].LoadFromStream (ms, ftGraphic);
finally
jpg.Free;
end;
finally
ms.Free;
bmp.Free;
end;
cmd.Execute;
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////
cmd - TADOCommand, it connected to db (TADOConnection)
if I build db.ConnectionString with "Microsoft OLE DB Provider for ODBC
Drivers" - all work fine; but in this case i need to create DSN to my
database - 1) i believe that Jet is best solution than ODBC and 2) i dont
know how to create DSN from my program
But all work fine (no errors, i can write data with images to DB and i can
read data from DB)
ok, i change ConnectionString for using Microsoft Jet 4.0 OLE DB Provider -
result: if i try to read data from db - all ok, but if i try to write data
in db: error "Syntacs error in INSERT INTO"
But my SQL work with ODBC!!!
What wrong?? Delphi7, WinXP, Office2003
wbr, Victor
p.s. sorry for my simple english
- Next message: Richard Caruana: "How to add results to ADOQuery and DBGrid for browsing"
- Previous message: ercan: "Re: create access table with ado sql (cannot change table properties)"
- Next in thread: Brian Bushay TeamB: "Re: delphi7 + ado: Jet vs ODBC"
- Reply: Brian Bushay TeamB: "Re: delphi7 + ado: Jet vs ODBC"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|