level 1
长虹64
楼主
我在网上上找了一个例子但照做后不能通过编译
http://www.docin.com/p-101024782.html
这个地址有七秒广告然后再出文本,不好意思
下面是我照做的全部代码,窗体上的控件和例子给的一样。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DB, DBTables, ExtDlgs;
type
TForm1 = class(TForm)
OpenPictureDialog1: TOpenPictureDialog;
Query1: TQuery;
Image1: TImage;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
procedure Image1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure addpictur(id,idname,photofile.name :strint);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.addpictur(id, idname,photofile.name: strint);
var
memorystream:Tmemorystream;
begin
with query1 do
begin
params.ParamValues[*id*]:=id;
params.ParamValues[*name*]:=name;
memorystream:=Tmemorystream.Create ;
memorystream.LoadFromFile(photofilename);
paramsbyname(*photo*).setblobdata(memorystream.Memory,memorystream.Size);
execsql;
memorystream.Free ;
end;
end;
procedure TForm1.Image1Click(Sender: TObject);
begin
if openpicturedialog1.Execute then
image1.Picture.LoadFromFile(openpicturedialog1.FileName );
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
addpicture(edit1.Text ,edit2.Text,openpicturedialog1.File.Name );
end;
end.
下面是编译时出的错误提示
[错误] Unit1.pas(22): Missing parameter type
[错误] Unit1.pas(36): Missing parameter type
[提示] Unit1.pas(22): Private symbol *addpictur* declared but never used
[致命错误] Project1.dpr(5): Could not compile used unit *Unit1.pas*
那个addpictur过程中的词句,我一句也没看懂。
params.ParamValues[*id*]:=id;
params.ParamValues[*name*]:=name;
这两句中的params.是什么意思?是query1控件的方法吗?
将id赋值给表中的id域,这个id 是哪来的啊?我看了半天也没在例子中看出来。后面哪个name赋值也是。
请哪位大侠指点一下,并将代码改一下能通过。谢谢
2014年08月28日 09点08分
1
http://www.docin.com/p-101024782.html
这个地址有七秒广告然后再出文本,不好意思
下面是我照做的全部代码,窗体上的控件和例子给的一样。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DB, DBTables, ExtDlgs;
type
TForm1 = class(TForm)
OpenPictureDialog1: TOpenPictureDialog;
Query1: TQuery;
Image1: TImage;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
procedure Image1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure addpictur(id,idname,photofile.name :strint);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.addpictur(id, idname,photofile.name: strint);
var
memorystream:Tmemorystream;
begin
with query1 do
begin
params.ParamValues[*id*]:=id;
params.ParamValues[*name*]:=name;
memorystream:=Tmemorystream.Create ;
memorystream.LoadFromFile(photofilename);
paramsbyname(*photo*).setblobdata(memorystream.Memory,memorystream.Size);
execsql;
memorystream.Free ;
end;
end;
procedure TForm1.Image1Click(Sender: TObject);
begin
if openpicturedialog1.Execute then
image1.Picture.LoadFromFile(openpicturedialog1.FileName );
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
addpicture(edit1.Text ,edit2.Text,openpicturedialog1.File.Name );
end;
end.
下面是编译时出的错误提示
[错误] Unit1.pas(22): Missing parameter type
[错误] Unit1.pas(36): Missing parameter type
[提示] Unit1.pas(22): Private symbol *addpictur* declared but never used
[致命错误] Project1.dpr(5): Could not compile used unit *Unit1.pas*
那个addpictur过程中的词句,我一句也没看懂。
params.ParamValues[*id*]:=id;
params.ParamValues[*name*]:=name;
这两句中的params.是什么意思?是query1控件的方法吗?
将id赋值给表中的id域,这个id 是哪来的啊?我看了半天也没在例子中看出来。后面哪个name赋值也是。
请哪位大侠指点一下,并将代码改一下能通过。谢谢