F
FlyDayDream
Unregistered / Unconfirmed
GUEST, unregistred user!
我要的是 n(5,1),
但是出现的是 n(16,1);
self.con1.Connected:=False;
self.con1.ConnectionString:=Format(sVfpStr4,[self.dir.text]);
try
self.con1.Connected:=True;
except
on E: Exception do
begin
MyShowMsg('连接dbf文件目录出错,请重试!',0,'',handle);
Abort;
end;
end;
ts.Clear;
str:='';
for i:=Pv_iTmin to Pv_iTmax do
begin
s:='T'+Myinttostr(i,2);
//str:=str+s+' N(5,1)'; //用 n(5,1) 他说不对
str:=Str+s+' Numeric(5,1)'; //用 numeric(5,1) ,实际的表是n(16,1)
if i< Pv_iTmax then str:=str+','
end;
//str:='MMh c(5),'+str;
str:='MMh char(5),'+str;
str:='Create Table XTF ('+STR+')';
ts.Add(str);
try
self.con1.Execute(Str);
except
on E: exception do
begin
MyShowMsg('创建表XTF.dbf出错~!'+#13+E.Message,0,'',Handle);
ts.SaveToFile(ExtractFilePath(Application.ExeName)+'Create_XTF.txt');
abort;
end;
end;
从sqlserver 到处数据到 dbf 表中,
procedure TfmExport.ExportXTF;
var
s,substr:string;
i,j,k:integer;
ts:tstrings;
begin
inherited;
ts:=Tstringlist.Create;
try
sqlstr:='';
substr:='';
//ts.Add(' Insert into XTF ');
s:=Format(' Insert into openrowset(''MSDASQL'', ''Driver=Microsoft Visual FoxPro Driver;SourceType=DBF;SourceDB=%s'', ''select * from XTF.DBF'')',[self.dir.text]) ;
ts.Add(s);
for i:=Pv_iTmin to Pv_iTmax do
begin
s:='T'+myinttostr(i,2);
substr:=substr+s;
if i<Pv_iTmax then substr:=substr+',';
end;
Substr:='select MMH,'+substr+' from B_XTF';
ts.Add(substr);
Try
myopenExecSQL(tmpqry,ts.Text,Handle);
except
on E: exception do
begin
MyShowMsg('导出小题分失败!'+e.Message,0,'',handle);
abort;
end;
end;
finally
ts.SaveToFile(ExtractFilePath(Application.ExeName)+'ExporT_XTF.txt');
ts.Free;
end;
end;
导出数据到已经存在的表(dbf)是成功了,但是导出后的哪个数据表(DBF), 就是用vfp 打不开,必须重启一下sqlserver 才能打开哪个dbf表, 为什么?
有重启sqlserver的语句,我想通过程序重启一下哪个sqlserver,不要手工重启。
但是出现的是 n(16,1);
self.con1.Connected:=False;
self.con1.ConnectionString:=Format(sVfpStr4,[self.dir.text]);
try
self.con1.Connected:=True;
except
on E: Exception do
begin
MyShowMsg('连接dbf文件目录出错,请重试!',0,'',handle);
Abort;
end;
end;
ts.Clear;
str:='';
for i:=Pv_iTmin to Pv_iTmax do
begin
s:='T'+Myinttostr(i,2);
//str:=str+s+' N(5,1)'; //用 n(5,1) 他说不对
str:=Str+s+' Numeric(5,1)'; //用 numeric(5,1) ,实际的表是n(16,1)
if i< Pv_iTmax then str:=str+','
end;
//str:='MMh c(5),'+str;
str:='MMh char(5),'+str;
str:='Create Table XTF ('+STR+')';
ts.Add(str);
try
self.con1.Execute(Str);
except
on E: exception do
begin
MyShowMsg('创建表XTF.dbf出错~!'+#13+E.Message,0,'',Handle);
ts.SaveToFile(ExtractFilePath(Application.ExeName)+'Create_XTF.txt');
abort;
end;
end;
从sqlserver 到处数据到 dbf 表中,
procedure TfmExport.ExportXTF;
var
s,substr:string;
i,j,k:integer;
ts:tstrings;
begin
inherited;
ts:=Tstringlist.Create;
try
sqlstr:='';
substr:='';
//ts.Add(' Insert into XTF ');
s:=Format(' Insert into openrowset(''MSDASQL'', ''Driver=Microsoft Visual FoxPro Driver;SourceType=DBF;SourceDB=%s'', ''select * from XTF.DBF'')',[self.dir.text]) ;
ts.Add(s);
for i:=Pv_iTmin to Pv_iTmax do
begin
s:='T'+myinttostr(i,2);
substr:=substr+s;
if i<Pv_iTmax then substr:=substr+',';
end;
Substr:='select MMH,'+substr+' from B_XTF';
ts.Add(substr);
Try
myopenExecSQL(tmpqry,ts.Text,Handle);
except
on E: exception do
begin
MyShowMsg('导出小题分失败!'+e.Message,0,'',handle);
abort;
end;
end;
finally
ts.SaveToFile(ExtractFilePath(Application.ExeName)+'ExporT_XTF.txt');
ts.Free;
end;
end;
导出数据到已经存在的表(dbf)是成功了,但是导出后的哪个数据表(DBF), 就是用vfp 打不开,必须重启一下sqlserver 才能打开哪个dbf表, 为什么?
有重启sqlserver的语句,我想通过程序重启一下哪个sqlserver,不要手工重启。