如何获取远端数据库的系统日期!!!(100分)

  • 主题发起人 主题发起人 金洪
  • 开始时间 开始时间
碰到这种问题,先查查Java APIdo
cument
getDate
public Date getDate(int columnIndex)
throws SQLExceptionRetrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.
Parameters:
columnIndex - the first column is 1, the second is 2, ...
Returns:
the column value;
if the value is SQL NULL, the value returned is null
Throws:
SQLException - if a database access error occurs
 
这是我一个c/s系统中使用的一个取远程sql server服务器时间的一个过程,你试试
function SetPCSystemTimeS_ADO: Boolean;
var
tSetDati: TDateTime;
vDatiBias: Variant;
tTZI: TTimeZoneInformation;
tST: TSystemTime;
v_adsServerTime: TADODataSet;
tDati: TDateTime;
begin
v_adsServerTime := TADODataSet.Create(nil);
try
v_adsServerTime.Connection := frmMain.ADOConnection1;
v_adsServerTime.CommandText := 'select getdate()';
v_adsServerTime.Open;
//showMessage( v_adsServerTime.Fields[0].AsString );
tDati := v_adsServerTime.Fields[0].AsDateTime;
finally
v_adsServerTime.Free;
end;

GetTimeZoneInformation(tTZI);
vDatiBias := tTZI.Bias / 1440;
tSetDati := tDati + vDatiBias;
with tSTdo
begin
wYear := StrToInt(FormatDateTime('yyyy', tSetDati));
wMonth := StrToInt(FormatDateTime('mm', tSetDati));
wDay := StrToInt(FormatDateTime('dd', tSetDati));
wHour := StrToInt(FormatDateTime('hh', tSetDati));
wMinute := StrToInt(FormatDateTime('nn', tSetDati));
wSecond := StrToInt(FormatDateTime('ss', tSetDati));
wMilliseconds := 0;
end;
SetPCSystemTimeS_ADO := SetSystemTime(tST);
 
TO 沙隆巴斯的主人:
我已经自己解决了,和你的想的一样应该是rs.getDate(1);不过谢谢你的帮助!去看看
自己的专家份!
 
后退
顶部