<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns:v = "urn:schemas-microsoft-com:vml" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word" xmlns:m =
"http://schemas.microsoft.com/office/2004/12/omml"><HEAD><TITLE>Message</TITLE>
<META content=text/html;charset=iso-8859-1 http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7600.16588">
<STYLE>@font-face {
        font-family: Calibri;
}
@font-face {
        font-family: Consolas;
}
@page WordSection1 {size: 8.5in 11.0in; margin: 1.0in 1.0in 1.0in 1.0in; }
P.MsoNormal {
        MARGIN: 0in 0in 0pt; FONT-FAMILY: "Calibri","sans-serif"; FONT-SIZE: 11pt
}
LI.MsoNormal {
        MARGIN: 0in 0in 0pt; FONT-FAMILY: "Calibri","sans-serif"; FONT-SIZE: 11pt
}
DIV.MsoNormal {
        MARGIN: 0in 0in 0pt; FONT-FAMILY: "Calibri","sans-serif"; FONT-SIZE: 11pt
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.EmailStyle17 {
        FONT-FAMILY: "Calibri","sans-serif"; COLOR: windowtext; mso-style-type: personal-compose
}
..MsoChpDefault {
        mso-style-type: export-only
}
DIV.WordSection1 {
        page: WordSection1
}
</STYLE>
</HEAD>
<BODY style="PADDING-LEFT: 10px; PADDING-RIGHT: 10px; PADDING-TOP: 15px"
id=MailContainerBody lang=EN-US leftMargin=0 link=blue topMargin=0 vLink=purple
CanvasTabStop="true" name="Compose message area">
<DIV>
<DIV><FONT size=2 face=Arial>Dealing with index/ID field that is set as binary -
here is the solution that worked in case any one else comes across
same....</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Note for MSSQL using such a field in a JOIN SQL
statement would be perfectly fine as normal, as MSSQL has a native binary
type. Delphi ADO however does not, so this is the hoops I had to
jump through when its two different datasets and I needed to get the value in
order to open the other with SQL or as a parameter....</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>example - using a Company_ID from Comp table to
open Contacts that belong to that Company...</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Comments from friends who know MSSQL - their
opinion is that an ID/index field that is binary is unusual practice - restricts
what kind to indexes can be made for instance. Anyone here have opinion on
this? have others come across ID/Index that is Binary
often?</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Step 1:</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial> ADOQueryComp.SQL.Text:='select *,
Cast(Company_ID as VARCHAR(10)) as ACompID, CAST(Company_ID as INT) as DCOMPID
from Company '+<BR> 'where Company_Name like
'+likestr;<BR></FONT></DIV>
<DIV><FONT size=2 face=Arial>Note - Casting binary to string/Varchar does not
work, but to integer does. Go figure!</DIV></FONT>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Step 2:</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>
iCompanyID:=cdsComp.FieldbyName('DCompID').asinteger;<BR></FONT></DIV>
<DIV><FONT size=2 face=Arial> ADOQueryContact.SQL.Text:='select * from
Contact '+<BR> 'where Company_ID =
CAST('+inttostr(iCompanyID)+' AS BINARY(8))';<BR></FONT></DIV></DIV>
<DIV><FONT size=2 face=Arial>John</FONT></DIV></BODY></HTML>