我将一个文本数据文件加载到数据库目标表中是没有问题的,下面是我的程序
procedure TDataLoadFrm.DataLoad(strFileName,strTableName,strDepart:string);
var
i,j: integer;
TextFileVar: TextFile;
temp: string;
StrLen, num: Integer;
DataSet:TDataSet;
begin
if strFileName = '' then exit;
AssignFile(TextFileVar, strFileName);
Reset(TextFileVar);
Readln(TextFileVar,temp); //表名信息
Readln(TextFileVar, temp); //字段信息
with adoQueryLoad do
begin
close;
sql.Clear;
sql.Add('select * from '+strTableName);
open;
end;
try
begin
while not SeekEof(TextFileVar) do
begin
Readln(TextFileVar, temp);
//得到标记数
StrLen := Length(trim(temp));
Num := 0;
for i := 1 to StrLen do
if Copy(temp, i, 1) = strDepart then
Num := Num + 1; //数据表列数
if pos(strDepart, temp) > 0 then
begin
adoQueryLoad.Append;
for j :=0 to Num-1 do
begin
adoQueryLoad.Fields[j].AsString := copy(Temp, 1, pos(strDepart, temp) - 1);
temp := copy(temp, pos(strDepart, temp) + 1, length(temp) - pos(strDepart, temp));
end;
end
else
adoQueryLoad.Fields[j].AsString := copy(Temp, 1, length(temp));
end;
//(????我现在要在adoQueryLoad.Post之前取得被插入的纪录集,并在dbgrid中显示出来)
adoQueryLoad.Post; showmessage('加载成功!');
end
except
showmessage('加载失败!');
end;
end;我用的是oracle数据库,如果要实现的必须先在库中新建临时表吗?
procedure TDataLoadFrm.DataLoad(strFileName,strTableName,strDepart:string);
var
i,j: integer;
TextFileVar: TextFile;
temp: string;
StrLen, num: Integer;
DataSet:TDataSet;
begin
if strFileName = '' then exit;
AssignFile(TextFileVar, strFileName);
Reset(TextFileVar);
Readln(TextFileVar,temp); //表名信息
Readln(TextFileVar, temp); //字段信息
with adoQueryLoad do
begin
close;
sql.Clear;
sql.Add('select * from '+strTableName);
open;
end;
try
begin
while not SeekEof(TextFileVar) do
begin
Readln(TextFileVar, temp);
//得到标记数
StrLen := Length(trim(temp));
Num := 0;
for i := 1 to StrLen do
if Copy(temp, i, 1) = strDepart then
Num := Num + 1; //数据表列数
if pos(strDepart, temp) > 0 then
begin
adoQueryLoad.Append;
for j :=0 to Num-1 do
begin
adoQueryLoad.Fields[j].AsString := copy(Temp, 1, pos(strDepart, temp) - 1);
temp := copy(temp, pos(strDepart, temp) + 1, length(temp) - pos(strDepart, temp));
end;
end
else
adoQueryLoad.Fields[j].AsString := copy(Temp, 1, length(temp));
end;
//(????我现在要在adoQueryLoad.Post之前取得被插入的纪录集,并在dbgrid中显示出来)
adoQueryLoad.Post; showmessage('加载成功!');
end
except
showmessage('加载失败!');
end;
end;我用的是oracle数据库,如果要实现的必须先在库中新建临时表吗?
解决方案 »
- delphi写的bho如何只被Internet Explorer浏览器加载
- 谁能帮我解决这个问题?共200分。谢谢
- 祝大家中秋节快乐
- 如何通过dbgrid组件实现数据更新!
- 控件拖动问题
- 高分求救!紧急求救!
- @@@@@有谁做过手持式扫描仪的应用@@@@@
- 菜鸟求救:怎么把数据库存的含有日期和时间的值,分别显示在datetimepicker和 edit上
- 請問﹕如何在計算字段的循環求和中避免dbgrid右邊的滾動條單擊而改變數據﹖
- Stringgrid 数据判别问题!急!!
- 如何制作一个IP地址输入框啊,并且能检测输入的正确性?
- 怎么判断XP里自带的防火墙功能有没启用,如果启用了怎么关了它(声明,我不是在做本马)。
我找到delphi里也可以创建recordset对象,但当我设置她的cursorLacation时老是类型不匹配:
var
rstFans:_Recordset;
begin
rstFans.CursorLocation:=clUseClient;//????
adUseServer = $00000002;
adUseClient = $00000003;
adUseClientBatch = $00000003;试一试直接付值:rstFans.CursorLocation:=$00000003;
我想问一下:delphi里的recordset对象是不是和vb中的一样呢?都是微软的东东?