I can't assign guid parameter .asguid, I have to pass guid as string and remove {} from string. Following example demostrates this
Code: Select all
var
c:tuniconnection;
uq: TUniQuery;
g: TGUID;
begin
c := TUniConnection.Create(nil);
c.ProviderName := 'ODBC';
c.server := 'Driver=Pervasive ODBC Unicode Interface;dbq=kirkar;ServerName=mylaptop';
c.LoginPrompt := FALSE;
c.Connected := true;
uq := tuniquery.Create(nil);
uq.connection := c;
uq.sql.text := 'drop table if exists guidtest ';
uq.execsql;
uq.SQL.Text := 'create table guidtest (g uniqueidentifier not null default newid(), text varchar(100), primary key(g))';
uq.ExecSQL;
uq.SQL.Text := 'insert into guidtest (text) values (''hello there'') ';
uq.ExecSQL;
uq.SQL.Text := 'select * from guidtest';
uq.open;
g := uq.FieldByName('g').AsGuid;
uq.Close;
uq.SQL.Text := 'update guidtest set text = :p1 where g= :p2';
uq.ParamByName('p1').AsString := 'will this work?';
uq.ParamByName('p2').AsGuid:= g;
uq.ExecSQL;
codesite.send('uq.rowsaffected', uq.rowsaffected);
uq.ParamByName('p1').AsString := 'how about this, will this work?';
uq.ParamByName('p2').asstring:= copy(g.ToString,2,36); // remove { }
uq.ExecSQL;
codesite.send('uq.rowsaffected', uq.rowsaffected);
Code: Select all
uq.rowsaffected = 0
uq.rowsaffected = 1
I there anything I can do or do I just have to tell my team to use asstring?