//定义一个全局变量
Gl_i_RowCount:integer;
//窗体显示事件中Gl_i_RowCount:=0
//添加SaveRecByteToDB到memo Change中去
function SaveRecByteToDB():integer;
var
S,Str_SQL:string;
Str_Field1,Str_Field2,Str_Field3:string;
sl_Datalist:TStringlist;
begin
Result:=0;
S:=mmo1.Text;
S:=stringreplce(S,' ','',[replaceall]); //先去掉空格
sl_Datalist.CommText=S;
if (sl_Datalist.Count>Gl_i_RowCount) and
(Length(sl_Datalist.strings[sl_Datalist.Count-1])=6) then
begin
Gl_i_RowCount:=Gl_i_RowCount+1;
Str_Field1:=Copy(S,1,2);
Str_Field2:=Copy(S,3,2);
Str_Field3:=Copy(S,5,2);
Str_SQL:=' Insert into Table(Field1,Field2,Field3) values('+
''''+Str_Field1+''''+','+
''''+Str_Field2+''''+','+
''''+Str_Field3+''''+')';
if ExecSQL(Str_SQL)<0 then //你自己写提交SQL函数,最基本的
begin
Result:=-1;
ShowMessage(Str_SQL);
Exit;
end;
end;
end;
温馨提示:答案为网友推荐,仅供参考