我用copyfile做的access的保存,其间用到了opendilalog,savedialog,本意是将open的文件修改后另存的,文件可复制,但delphi老报错“unsafe type ‘pchar’”,有哪位知道是什么意思么?单独别的用话程序是不报错的,但用在我的程序中就报这个错,郁闷啊!!郁闷啊!!!
我的email是[email protected]
求各位帮帮忙介绍一下copyfile的具体用法,最好能有关于opendialog和savedialog的保存源码,邮寄给我,不胜感激。。
我的email是[email protected]
求各位帮帮忙介绍一下copyfile的具体用法,最好能有关于opendialog和savedialog的保存源码,邮寄给我,不胜感激。。
CopyFile(Pchar('源路径'),Pchar('保存的路径'), false);
楼主肯定是少了 Pchar :)
粗学不是错
但是 砸道? 把道路砸了?大家怎么走路肋?:)呵呵。。
var
myaccess:string;
const
link_str='Provider=%s; Data Source=%s';
dataprovider='microsoft.jet.oledb.4.0';begin
opendialog1.FileName :='*.mdb';
if opendialog1.Execute then
begin
myaccess:=opendialog1.FileName;
edit1.Text :=myaccess ;
alldata.adoconnection1.Connected :=false;
alldata.adoconnection1.ConnectionString :=format(link_str,[dataprovider,myaccess]);
alldata.ADOConnection1.connected:=true;
alldata.ADOTable2.Active:=true;
alldata.ADOQuery2.Active:=true;
end;
end;procedure Tmainform.N33Click(Sender: TObject);//切断adoconection的联系
begin
alldata.ADOTable2.close;
alldata.ADOQuery2.Close;
alldata.ADOConnection1.Connected:=false;
edit2.Text:=edit1.Text;
edit1.Text:='';end;procedure Tmainform.N35Click(Sender: TObject);//我写的保存
var
EXEPATH:String;
access:string;
const
link_str='Provider=%s; Data Source=%s';
dataprovider='microsoft.jet.oledb.4.0';
begin
opendialog1.FileName :='*.mdb';
access:=opendialog1.FileName;
try
if not savedialog1.Execute then exit;
if FileExists(savedialog1.FileName+'.mdb') then
begin
if Messagebox(handle,'存在数据库重名,是否覆盖?','存盘选项',mb_iconquestion+mb_yesno)=IDNo then Exit;
end
else
begin
EXEPATH:=opendialog1.FileName;
CopyFile(PChar(edit2.text),PChar(SaveDialog1.FileName+'.mdb'),True);
Messagebox(handle,'数据库备份成功!','备份数据',mb_iconinformation+mb_ok);
end;
except
Messagebox(handle,'警告:数据库备份失败!','存盘错误',mb_iconwarning+mb_ok);
end;
end;
能发现哪写错了,以至包错unsafe type pchar么?