
fieldbyname('field1').asString:= myDBGridTable.fieldbyname('field1').asString You have to go through the TTable and put it to another TTable.įirst make a connection to the DB file with another TTable and together with your TTable of the DBGrid you copy the one in the other like: That is just the view of the TTable or TQuery you used. So, now you have put a stringgrid in a dbgrid, you want to put the dbgrid to another DB? Thought for those who agree with us but freedom for the thought that we

DELPHI XE10 TQUERY SAVETOFILE FREE
"If there is any principle of the Constitution that more imperatively callsįor attachment than any other it is the principle of free thought, not free

Posted to the database, whether editing an existing row or adding another. Then edit directly in the dbgrid and when you move off that row, it will be There are records in the table or query the dataset is assigned to). You open the dataset and you should see data display in the dbgrid (assuming What database you are using, if using the BDE then that would TTable or TDatasource, which in turn links to a TDataset descendant (which depends on Other controls on the same tool palette page.

DB file (databaseĪ dbgrid (TDBGrid that comes with Delphi) is data-aware. > How do I take a populated dbgrid and save it to a. Up till now, applications I wrote never relied on the use of 注意:选择【Project | View Source】,可以创建一个缺省的Delphi项目文件的源代码(.DPR),修改后双击它打开对应的项目,避免点击启动时总是启动其他项目。ĭataInMysqlin 'DataInMysql."Cory Herlihy" wrote in message have recently started using databases and dbgrids in a new project I am ProcedureTForm1.btn1Click(Sender: TObject) vars:string begins:='SELECT * FROM DEMOUSER where 1=1' if edt1.Text'' thenīegins:=s+'and id='+edt1.Text end with qry1 do UsesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,ĭialogs, StdCtrls, DB, ADODB,ComObj, Grids, DBGrids, ExtCtrls typeTForm1= class(TForm)Įdt1: TEdit procedurebtn1Click(Sender: TObject) private Procedure TForm1.ReadClick(Sender: TObject) // 读取图片var Stream:TMemoryStream Jpg:TjpegImage begin ADOQuery1.Close :='SELECT * FROM test3 where id =' + editId.Text // 查询图片 ADOQuery1.Open if not ADOQuery1.FieldByName('photo').IsNull then begin Stream:=TMemoryStream.Create Jpg:=TjpegImage.Create TBlobField(ADOQuery1.FieldByName('photo')).SaveToStream(Stream) // 显示的转换为BlobField并保存到内存流 Stream.Position :=0 jpg.LoadFromStream(Stream) // 加载图片 (Jpg) end else begin image2.Picture :=nil end (OpenPictureDialog1.FileName) (另一种方法) adoquery1.Close ('Insert into test3 values (:id,:photo)') ('id').Value := editId.Text ('photo').LoadFromStream(Stream,ftBlob) // 读取保存的内存图 adoquery1.ExecSQL finally Stream.Free // 释放内存流 end end

Procedure TForm1.saveClick(Sender: TObject) //保存var Stream:TMemoryStream begin try Stream := TMemoryStream.Create // 创建内存流 (Stream) // 将图片保存到内存流中 Procedure TForm1.LoadPictureClick(Sender: TObject) // 上传图片begin OpenPictureDialog1.Title := '打开图片' if OpenPictureDialog1.Execute then begin (OpenPictureDialog1.FileName) end end Fields.FieldName) + ' ', AKeyField) > 0) then UpdateTableData(ATableName, AKeyField: AnsiString var AData: Variant): Boolean
