在下用Delphi7+SQL Server 2000编一小程序,对SQL有一定基础,刚接触学D7大概10天
想通过如图的“清空表”这个按钮把SQL数据库表清空,通过“导入表”按钮把*.txt格式或者*.xls格式的表导入到SQL表,经过处理后的表通过“另存为”按钮保存为Excel表格。现在的问题是“清空表”这个按钮根据书里学的知识已经编好代码,但运行有错,“导入和导出”按钮不知道怎么做,请高手帮看看我写的“清空表”按钮代码错在哪?还有“导入和导出”到底用到那些知识,如详细告诉步骤更好,在此感激不尽!!!!!
unit Unit11;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, Grids, DBGrids, StdCtrls, Buttons;
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
BitBtn1: TBitBtn;
Button1: TButton;
ADOQuery1: TADOQuery;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
with ADOQuery1 do
begin
Close;
with SQL do
begin
clear;
Add('delete from mmbb');
end;
ExecSQL;
end ;
end;
end.
运行“清空表”时错误提示为:
“Access violation at address 1F487CAB in module 'msado15.dll' write of address 01118024”
[此贴子已经被作者于2006-5-15 0:05:05编辑过]