社区
Delphi
帖子详情
ADO的问题(急&在线等待)
No_1gogo
2002-07-16 10:36:31
怎么用ADO的控件,动态的建表啊,adoquery和adotable都行,最好是用adotable。
...全文
34
1
打赏
收藏
ADO的问题(急&在线等待)
怎么用ADO的控件,动态的建表啊,adoquery和adotable都行,最好是用adotable。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
1 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
chenjiong
2002-07-16
打赏
举报
回复
nit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, comobj,adox_tlb,Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Catalog: _Catalog;
Table: _Table;
Index : _Index;
//FKey : _key;
strCon:string;//定义连接字符串
yourname:string;
yourpwd:string;
begin
yourname:=trim(edit1.Text);
yourpwd:=trim(edit2.text);
Catalog := CoCatalog.Create;
strCon := 'Provider=Microsoft.Jet.OleDB.4.0;'
//通过Jet OleDb直接操作Access数据库
+'Data Source=c:\windows\desktop\'+yourname+'.mdb;'
//数据库位置
+'Jet OLEDB:Engine Type=5;'
//Jet 4.x格式,如为4,则Jet 3.x格式
+'Locale Identifier=0x0804;'
//支持简体中文(一定要有)
+'Jet OLEDB:Database Password='+yourpwd;//修改密码也在此;
//加入密码
Catalog.Create(strCon); //建立数据库
{建立数据表和索引}
Catalog.Set_ActiveConnection(strCon);
//连接到数据库
with Catalog do
begin //建立数据表
Table:= CoTable.Create(); //建立Table实例
with Table do
begin
Name := 'MyTable1'; //建表 MyTable1
Table.ParentCatalog := Catalog ;
Columns.Append('ID',adInteger,8);
Columns.Item['ID'].Properties.Item['AutoIncrement'].Value := true;
Columns.Append('Name',adVarWChar,40);
Columns.Append('Parent_ID',adInteger,8);
Columns.Item['Parent_ID'].Properties['Default'].Value := 0;
Columns.Append('Sort_ID',adInteger,8);
Columns.Append('Counter',adInteger,8);
Columns.Item['Counter'].Properties.Item['Default'].Value := 0;
//数据类型详见MDAC SDK
Tables.Append(Table); //建表 MyTable1
Index := CoIndex.Create() as _Index; //建立索引
with Index do
begin
Name:='Idx1';
PrimaryKey := True ;
Unique := True;
Columns.Append('ID',adInteger,8);
_Release;
end;
Table.Indexes.Append(Index,EmptyParam);
Table._Release;
Table:= CoTable.Create();
end; //with table do
end; //with catalog do
end;
全面掌握
ADO
模块常用功能与实战应用
我们可以总结出构建高质量
ADO
应用的五大基石:连接管理:显式控制生命周期,善用连接池参数化查询:杜绝 SQL 注入,提升安全性事务控制:保障复杂业务的数据一致性错误处理:利用Errors集合精准定位
问题
模块封装:...
多表操作比较的
问题
?
在线
等待
!!
在线
等待
!! Delphi / Windows SDK/APIhttp://www.delphi2007.net/DelphiDB/html/delphi_20061216123719269.html 请大家帮个忙!我有两个数据表:基础数据表(编号,数据类型,数据项目,指标上界,指标下界,标准分)和数据...
VB+
ADO
+Access如何修改数据
我把用
ado
dc1绑定了表Case,并在窗体中用几个Text跟表Case中的对应字段相绑定,我现在想直接通过修改Text(i).text来修改数据库表Case中的记录,问该如何修改,大侠们可否提供一下建议,并帮忙看看我的
问题
出在哪儿 ...
ADO
.NET在WinForms中的深度实战:从“连接池混乱“到“毫秒级响应“的蜕变之路
摘要: 本文深入探讨了WinForms中
ADO
.NET的常见误用与优化策略。通过分析一个典型错误案例(频繁创建连接、SQL拼接漏洞、线程安全
问题
),揭示了性能瓶颈根源。作者提出了五项关键优化方案:1)连接池深度配置;2)...
.net中访问oracle数据库的几种方式
请大家在浏览器中输入地址(ORACLE的网站有点慢,请不要
急
) http://www.oracle.com/technology/tech/windows/odpnet/faq.html#install Q: What do I need to have installed on my client machine to have ODP.NET ...
Delphi
5,930
社区成员
262,943
社区内容
发帖
与我相关
我的任务
Delphi
Delphi 开发及应用
复制链接
扫一扫
分享
社区描述
Delphi 开发及应用
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章