Patch for TZASAResultSet

Code patches written by our users to solve certain "problems" that were not solved, yet.

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
Ostfriese
Junior Boarder
Junior Boarder
Posts: 25
Joined: 12.05.2009, 10:48
Location: Coburg
Contact:

Patch for TZASAResultSet

Post by Ostfriese »

I've modified the UpdateUnicodeString procedure to avoid a compiler warning claiming a dangerous typecast

Code: Select all

procedure TZASAResultSet.UpdateUnicodeString(ColumnIndex: Integer; const Value: WideString);
begin
  PrepareUpdateSQLData;
  //HA 090515 fix dangerous typecast
  //FUpdateSqlData.UpdatePChar( ColumnIndex, PChar( Value));
  FUpdateSqlData.UpdatePChar( ColumnIndex, PChar( PWideChar(Value)));
end;
Thomas Jefferson wrote:Information ist die Währung der Demokratie
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Would this also be solved using the construct we used to get Testing branch compiled on D2009?

Code: Select all

procedure TZASAResultSet.UpdateUnicodeString(ColumnIndex: Integer; const Value: WideString);
begin
  PrepareUpdateSQLData;
  FUpdateSqlData.UpdatePChar(ColumnIndex, PAnsiChar(string(Value)));
end;

Mark
Image
paripalu
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 28.08.2010, 09:06

Post by paripalu »

You can't call ToString on a null reference in C#, it throws a NullReferenceException.
You would need to do this:
Object o = cmd.ExecuteScalar();
if(o != null)
ss = o.ToString();
else
// Not Found code here.
==================
Best Life Insurance | Buy Life Insurance
Post Reply