1.先把要转移的数据查询出来:<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> v_sql:string;<br>begin<br> //12-3以前(含3号)<br> v_sql:=' select s.a,s.b,s.c,to_char(s.d,''yyyy-mm-dd hh24:mi:ss'')'<br> +' from Sales s where adddate<=to_date(''2007-12-3'',''yyyy-mm-dd'')+1';<br> //可以直接双击设置ADOConnection1.ConnectionString<br> //v_str:='Provider=Microsoft.Jet.OLEDB.4.0;'; //用access<br> //v_str:=v_str+'Password= ;User ID= ;'; //密码 用户名<br> //v_str:=v_str+'Data Source=D:/DB/S.mdb;'; //S的路径<br> //v_str:=v_str+'Persist Security Info=True ';<br> //ADOConnection1.ConnectionString:=v_str; <br> //ADOQuery1.Connection:=ADOConnection1 <br> if ADOQuery1.Active then ADOQuery1.Close;<br> ADOQuery1.SQL.Text:=v_Sql;<br> ADOQuery1.Open;<br>end;<br>2.存储到笔记本<br>procedure TForm1.Button2Click(Sender: TObject);<br>var<br> v_sql,v_str:string;<br>begin<br> v_sql:=' insert into Sales N(N.a,N.b,N.c,N.d) '<br> +' values('<br> +ADOQuery1.FieldByName('s.a').AsString<br> +', '''+ADOQuery1.FieldByName('s.b').AsString+'''' //b字段是字符串<br> +', '+ADOQuery1.FieldByName('s.c').AsString<br> +', to_date('''+ADOQuery1.FieldByName('s.d').AsString+''',''yyyy-mm-dd hh24:mi:ss'')';<br> //可以直接双击设置ADOConnection1.ConnectionString<br> //v_str:='Provider=Microsoft.Jet.OLEDB.4.0;'; //用access<br> //v_str:=v_str+'Password= ;User ID= ;'; //密码 用户名<br> //v_str:=v_str+'Data Source=D:/DB/N.mdb;'; //N的路径<br> //v_str:=v_str+'Persist Security Info=True ';<br> //ADOConnection2.ConnectionString:=v_str;<br><br> ADOQuery2.Connection:=ADOConnection2;<br> ADOQuery2.SQL.Text:=v_Sql;<br> ADOQuery2.ExecSQL;<br>//3.删除原数据<br> v_sql:=' delect * from Sales S where adddate<=to_date(''2007-12-3'',''yyyy-mm-dd'')+1';<br> ADOQuery1.SQL.Text:=v_Sql;<br> ADOQuery1.ExecSQL;<br>end;