| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1038 人关注过本帖
标题:[求助]undeclared indentifier:'datatype'
只看楼主 加入收藏
proholy
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2006-6-8
收藏
 问题点数:0 回复次数:0 
[求助]undeclared indentifier:'datatype'

其中datatype用紫色标出
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, DBTables, ADODB, DB;

type
TForm1 = class(TForm)
Table1: TTable;
ADOTable1: TADOTable;
ADOCommand1: TADOCommand;
Database1: TDatabase;
ComboBox1: TComboBox;
ListBox1: TListBox;
Panel1: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
ADOConnection1: TADOConnection;
Panel2: TPanel;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
session.GetAliasNames(combobox1.Items);
bitbtn1.Enabled:=false;
bitbtn2.Enabled:=false;
bitbtn3.Enabled:=false;
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
session.GetTableNames(combobox1.Items[combobox1.itemindex],'.db',false,false,listbox1.Items);
end;

procedure TForm1.ListBox1Click(Sender: TObject);
begin
bitbtn1.Enabled:=true;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
var
I:integer;
tablelist:tstringlist;
str:string;
flddef:tfielddef;
begin
table1.DatabaseName:=combobox1.Items[combobox1.Itemindex];
//获取数据库名称
table1.TableName:=listbox1.Items[listbox1.itemindex];
//取得要连接的表名
adotable1.TableName:=table1.TableName;
memo1.Lines.Clear;
//清除memo1控件中的内容
tablelist:=tstringlist.Create;
//生成tstringlist对象
adoconnection1.GetTableNames(tablelist);
//生成SQL语句
if tablelist.IndexOf(adotable1.TableName)<0 then
memo1.Lines.Add('create table'+adotable1.TableName+'(')
else
memo1.Lines.Add('create table'+adotable1.TableName+'new(');
table1.FieldDefs.Update;
for i:=0 to table1.FieldDefs.Count-1 do
begin
flddef:=table1.FieldDefs[i];
str:=''+table1.FieldDefs[i].Name+''+datatype(flddef);
if i=table1.FieldDefs.Count-1 then
str:=str+');'
else
str:=str+',';
memo1.Lines.Add(str);
end;
//设置按钮的可用状态
bitbtn2.Enabled:=true;
bitbtn3.Enabled:=true;
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
adocommand1.CommandText:=memo1.Text;
//获取SQL语句
adocommand1.Execute;
//执行SQL语句
end;

procedure TForm1.BitBtn3Click(Sender: TObject);
var
I:integer;
begin
table1.Open;
//打开表
adotable1.Open;
try
//依次读取表中的数据
while not table1.Eof do
begin
adotable1.Insert;
for i:=0 to table1.fielddefs.count-1 do
begin
with table1.Fields[i] do
adotable1.FieldByName(table1.FieldDefs[i].Name).Value:=value;
adotable1.Post;
table1.Next;
end;
end;
finally
table1.Close;
//关闭表
adotable1.Close;
end;
end;
end.

搜索更多相关主题的帖子: datatype indentifier undeclared 
2006-08-04 16:26
快速回复:[求助]undeclared indentifier:'datatype'
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.045114 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved