小弟现在有表orderrelation里面有字段:FeeUser,DestUser,ActionID,ActionReasonID,ServiceID
,AccessMode,FeatureStr,OrderTime,CancelTime
现在要将(.txt)文本里面的相应的字段里面的数据写进这个表中相应的字段中,(.txt)文本里面的格式为:===================Trace=====================
SOAP Body:
MsgType: SyncOrderRelationReq
Version: 1.5.0
Send_Address:
DeviceType: 0
DeviceID: 999
Dest_Address:
DeviceType: 400
DeviceID: 917014
FeeUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
DestUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
LinkID: SP
ActionID: 1
ActionReasonID: 1
SPID: 917014
SPServiceID: 6102
AccessMode: 3
FeatureStr: (null)
===================Trace========================================Trace=====================
SOAP Body:
MsgType: SyncOrderRelationReq
Version: 1.5.0
Send_Address:
DeviceType: 0
DeviceID: 999
Dest_Address:
DeviceType: 400
DeviceID: 917014
FeeUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
DestUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
LinkID: SP
ActionID: 1
ActionReasonID: 1
SPID: 917014
SPServiceID: 6102
AccessMode: 3
FeatureStr: (null)
===================Trace========================================Trace=====================
SOAP Body:
MsgType: SyncOrderRelationReq
Version: 1.5.0
Send_Address:
DeviceType: 0
DeviceID: 0011
Dest_Address:
DeviceType: 400
DeviceID: 0
FeeUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
DestUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
LinkID: SP
ActionID: 2
ActionReasonID: 1
SPID: 917014
SPServiceID: 6813
AccessMode: 3
FeatureStr: (null)
===================Trace========================================Trace=====================
SOAP Body:
MsgType: SyncOrderRelationReq
Version: 1.5.0
Send_Address:
DeviceType: 0
DeviceID: 0011
Dest_Address:
DeviceType: 400
DeviceID: 0
FeeUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
DestUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
LinkID: SP
ActionID: 2
ActionReasonID: 1
SPID: 917014
SPServiceID: 6201
AccessMode: 3
FeatureStr: (null)
===================Trace========================================Trace=====================
..............................................
===================Trace=====================(注意中间有空格)希望老大们给出相应的原代码。谢谢!!!,小弟非常急!!!!!!!
,AccessMode,FeatureStr,OrderTime,CancelTime
现在要将(.txt)文本里面的相应的字段里面的数据写进这个表中相应的字段中,(.txt)文本里面的格式为:===================Trace=====================
SOAP Body:
MsgType: SyncOrderRelationReq
Version: 1.5.0
Send_Address:
DeviceType: 0
DeviceID: 999
Dest_Address:
DeviceType: 400
DeviceID: 917014
FeeUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
DestUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
LinkID: SP
ActionID: 1
ActionReasonID: 1
SPID: 917014
SPServiceID: 6102
AccessMode: 3
FeatureStr: (null)
===================Trace========================================Trace=====================
SOAP Body:
MsgType: SyncOrderRelationReq
Version: 1.5.0
Send_Address:
DeviceType: 0
DeviceID: 999
Dest_Address:
DeviceType: 400
DeviceID: 917014
FeeUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
DestUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
LinkID: SP
ActionID: 1
ActionReasonID: 1
SPID: 917014
SPServiceID: 6102
AccessMode: 3
FeatureStr: (null)
===================Trace========================================Trace=====================
SOAP Body:
MsgType: SyncOrderRelationReq
Version: 1.5.0
Send_Address:
DeviceType: 0
DeviceID: 0011
Dest_Address:
DeviceType: 400
DeviceID: 0
FeeUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
DestUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
LinkID: SP
ActionID: 2
ActionReasonID: 1
SPID: 917014
SPServiceID: 6813
AccessMode: 3
FeatureStr: (null)
===================Trace========================================Trace=====================
SOAP Body:
MsgType: SyncOrderRelationReq
Version: 1.5.0
Send_Address:
DeviceType: 0
DeviceID: 0011
Dest_Address:
DeviceType: 400
DeviceID: 0
FeeUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
DestUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
LinkID: SP
ActionID: 2
ActionReasonID: 1
SPID: 917014
SPServiceID: 6201
AccessMode: 3
FeatureStr: (null)
===================Trace========================================Trace=====================
..............................................
===================Trace=====================(注意中间有空格)希望老大们给出相应的原代码。谢谢!!!,小弟非常急!!!!!!!
数据库字段 文本字段
FeeUser (FeeUser_ID)MSISDN
DestUser (DestUser_ID)MSISDN
ActionID ActionID
ActionReasonID ActionReasonID
ServiceID SPServiceID
AccessMode AccessMode
FeatureStr FeatureStr
OrderTime (当前时间)
CancelTime (当前时间)
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, DB, DBTables, Grids, DBGrids;type
Torderrelation= record
FeeUser : String;
DestUser : String;
ActionID : String;
ActionReasonID : String;
ServiceID : String;
AccessMode : String;
FeatureStr : String;
OrderTime : String;
CancelTime : String;
end;
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Memo2: TMemo;
Button2: TButton;
OpenDialog1: TOpenDialog;
Button3: TButton;
Database1: TDatabase;
Query1: TQuery;
Table1: TTable;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
var
f:textfile;
s:string;
i,j:integer;
begin
if opendialog1.Execute then
begin
memo1.Clear;
i:=0;
j:=0;
AssignFile(F, OpenDialog1.FileName); { File selected in dialog }
Reset(F);
while not eof(f) do
begin
Readln(F, S); { Read first line of file }
memo1.Lines.Append(s);
inc(i);
end;
end;
CloseFile(F);
showmessage('导入完毕!');
button2.Enabled:=true;
//button3.Enabled:=true;
end;
//end;procedure TForm1.Button2Click(Sender: TObject);
var
i,j : integer;
x : Torderrelation;
temp : String;
begin
// x := Torderrelation.Create;
Memo2.Lines.Clear;
for i := 0 to Memo1.Lines.count-1 do
begin
temp := copy(Memo1.Lines[i],1,14);
j := length(Memo1.Lines[i]);
if copy(Memo1.Lines[i],1,10) = 'FeeUser_ID'then
x.FeeUser := copy(trim(Memo1.Lines[i+2]),9,length(trim(Memo1.Lines[i+2]))-8);
if copy(Memo1.Lines[i],1,11) = 'DestUser_ID' then
x.DestUser :=copy(trim(Memo1.Lines[i+2]),9,length(trim(Memo1.Lines[i+2]))-8);
if copy(Memo1.Lines[i],1,8) = 'ActionID' then
x.ActionID := Copy(Memo1.Lines[i],10,length(Memo1.Lines[i])-9);
if copy(Memo1.Lines[i],1,14) ='ActionReasonID' then
x.ActionReasonID := Copy(Memo1.Lines[i],16,length(Memo1.Lines[i])-14);
if copy(Memo1.Lines[i],1,11) ='SPServiceID' then
x.ServiceID := Copy(Memo1.Lines[i],13,length(Memo1.Lines[i])-11);
if copy(Memo1.Lines[i],1,10) ='AccessMode' then
x.AccessMode := Copy(Memo1.Lines[i],12,length(Memo1.Lines[i])-10);
if copy(Memo1.Lines[i],1,10) ='FeatureStr' then
begin
x.FeatureStr := Copy(Memo1.Lines[i],12,length(Memo1.Lines[i])-10);
x.OrderTime := TimeToStr(Time);
x.CancelTime := TimeToStr(Time);
Memo2.Lines.Add(x.FeeUser);
Memo2.Lines.Add(x.DestUser);
Memo2.Lines.Add(x.ActionID);
Memo2.Lines.Add(x.ActionReasonID);
Memo2.Lines.Add(x.ServiceID);
Memo2.Lines.Add(x.AccessMode);
Memo2.Lines.Add(x.FeatureStr);
Memo2.Lines.Add(x.OrderTime);
Memo2.Lines.Add(x.CancelTime);
Memo2.Lines.Add('----------------------------------------------');
end;
end;
button2.Enabled:=false;
button3.Enabled:=true;end;procedure TForm1.Button3Click(Sender: TObject);
var
i : integer;
x : Torderrelation;
begin
memo2.Clear;
button2.Enabled:=false;
i := 0;
query1.Active := true;
while i <= memo2.Lines.count-1 do
begin
x.FeeUser := memo2.Lines[i];
x.DestUser := memo2.Lines[i+1];
x.ActionID := memo2.Lines[i+2];
x.ActionReasonID := memo2.Lines[i+3];
x.ServiceID := memo2.Lines[i+4];
x.AccessMode := memo2.Lines[i+5];
x.FeatureStr := memo2.Lines[i+6];
x.OrderTime := memo2.Lines[i+7];
x.CancelTime:= memo2.Lines[i+8];
i := i+10;
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('insert into orderrelation values(:a,:b,:c,:d,:e,:f,:g,:h,:i)');
query1.ParamByName('a').AsString:=x.FeeUser;
query1.ParamByName('b').AsString:=x.DestUser;
query1.ParamByName('c').AsInteger:=strtoint(x.ActionID);
query1.ParamByName('d').AsInteger:=StrToInt(x.ActionReasonID);
query1.ParamByName('e').AsString:=x.ServiceID;
query1.ParamByName('f').AsInteger:=StrToInt(x.AccessMode);
query1.ParamByName('g').AsString:=x.FeatureStr;
query1.ParamByName('h').AsString:=x.OrderTime;
query1.ParamByName('i').AsString:=x.CancelTime;
//end;
query1.ExecSQL;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
button2.Enabled:=false;
button3.Enabled:=false;
end;end.