Solved

Timestamps (binary) and SQL-Server/ADO-Clientside but using queries/Delphi

Posted on 2003-12-05
1
447 Views
Last Modified: 2010-04-03
I'm using SQL-Server 2k and Delphi-ADO/ClientSide Cursors but use queries...

I populate a combobox with all the records.  

I have included a timestamp column in my table.  ( i understand its not for date/time values)

What i need is whenever I select an item from the combobox, to check if the time stamp changed from the last time it was read, and if that's true then to remove and reinsert the value inside the combobox... At the moment i'm doing it like this:

x := Combo.ItemIndex;

if Combo.Text <> Query.FieldByName('ColumnName').AsString then
   begin
      Combo.Items.Delete(x);
      Combo.Items.Insert(x,Query.FieldByName('ColumnName').AsString);
      Combo.ItemIndex := x;
   end;

But i need to use TimeStamps...

Any ideas appreciated...

0
Comment
Question by:nick-p
1 Comment
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 500 total points
ID: 9891461
Hello

  I found this function in borland newsgroups that will allow you to read the TimeStamp field as string,

type
  SQLTimestamp = array [0..7] of Byte;
  PSQLTimestamp = ^SQLTimestamp;

function TSToStr(const vTS: Variant): string;
  var
    p: PSQLTimestamp;
begin
  p := VarArrayLock(vTS);
  try
    Result := Format('0x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x',
    [p^[0], p^[1], p^[2], p^[3], p^[4], p^[5], p^[6], p^[7]]);
  finally
     VarArrayUnlock(vTS);
  end;
end;

and you can easily read the TimeStamp field and convert it string, that you compare it or doing whatever you want

procedure TForm1.Button1Click(Sender: TObject);
var
  V : Variant;
begin
  V := AdoTable1['MyTimeStamp'];
  ShowMessage(TSToStr(V));
end;

HTH

Regards,
Mohammed
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now