delphi动态连接access数据库
unitUnit1;interfaceconstfeng:char='Provider=Microsoft.Jet.OLEDB.4.0;DataSource=%s\数据库...
unit Unit1;
interface
const feng:char= 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s\数据库\db1.mdb'
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DBCtrls, DB, ADODB, Grids, DBGrids;
type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
DataSource1: TDataSource;
ADOTable1: TADOTable;
DBText1: TDBText;
DBText2: TDBText;
DBText3: TDBText;
DBText4: TDBText;
Timer1: TTimer;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled :=not timer1.Enabled;
if button1.Caption='开始' then button1.Caption:='停止'
else button1.Caption:='开始'
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if not adotable1.Eof then adotable1.Next
else adotable1.First;
end;
end.
在定义了常量feng以后就无法调用adotable控件,请教高手如何解决
2小时内解决追加30分
char 应该为string ,代码检查后无错误 展开
interface
const feng:char= 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s\数据库\db1.mdb'
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DBCtrls, DB, ADODB, Grids, DBGrids;
type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
DataSource1: TDataSource;
ADOTable1: TADOTable;
DBText1: TDBText;
DBText2: TDBText;
DBText3: TDBText;
DBText4: TDBText;
Timer1: TTimer;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled :=not timer1.Enabled;
if button1.Caption='开始' then button1.Caption:='停止'
else button1.Caption:='开始'
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if not adotable1.Eof then adotable1.Next
else adotable1.First;
end;
end.
在定义了常量feng以后就无法调用adotable控件,请教高手如何解决
2小时内解决追加30分
char 应该为string ,代码检查后无错误 展开
3个回答
展开全部
连接字符串feng在哪里调用了吗?
应该是要把adotable这个控件里的数据库连接属性设置为feng,再才能打开连接吧。况且还不知道你那个连接字符串有没有错误,最好先用完整路径试一下。
应该是要把adotable这个控件里的数据库连接属性设置为feng,再才能打开连接吧。况且还不知道你那个连接字符串有没有错误,最好先用完整路径试一下。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
因为你没有设置你的常量为adotable的connectionstring属性,
你在添句话:adotable1.connectionstring:=feng;
你在看看行不?
祝你学习愉快
你在添句话:adotable1.connectionstring:=feng;
你在看看行不?
祝你学习愉快
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询