unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,comobj, DB, ADODB;type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
ADOConnection1: TADOConnection;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
mycn:variant;
myrs:variant;
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var
myconnstr:string;
begin
mycn:=CreateoleObject('adodb.connection');
myrs:=createoleobject('adodb.recordsetr'); myconnstr:='Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=STUDENTS1.mdb;Persist Security Info=False ';
mycn.open(myconnstr);
myrs.open('select * from 成绩单 where 语文 >60',mycn);end;end.
上面的程序编译无错,运行时出错,什么原因?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,comobj, DB, ADODB;type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
ADOConnection1: TADOConnection;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
mycn:variant;
myrs:variant;
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var
myconnstr:string;
begin
mycn:=CreateoleObject('adodb.connection');
myrs:=createoleobject('adodb.recordsetr'); myconnstr:='Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=STUDENTS1.mdb;Persist Security Info=False ';
mycn.open(myconnstr);
myrs.open('select * from 成绩单 where 语文 >60',mycn);end;end.
上面的程序编译无错,运行时出错,什么原因?
改成
myrs.open('select * from "成绩单" where "语文" >60',mycn);
试试
改成
myrs:=createoleobject('adodb.recordset');试试