so I have a DBGRID that has this infos :
I wanted to edit values inside that DBGRID. I provide a button with codes :
var ptlok, idp, tgl, after, kode, jlh, sql, sqla:string;
begin
while not dbgrid2.DataSource.DataSet.Eof do
begin
ptlok:=dbgrid2.DataSource.DataSet.Fields[0].AsString;
tgl:=dbgrid2.DataSource.DataSet.Fields[1].AsString;
after := stringreplace(tgl, '/', '-', [rfReplaceAll, rfIgnoreCase]);
kode:=dbgrid2.DataSource.DataSet.Fields[2].AsString;
jlh:=dbgrid2.DataSource.DataSet.Fields[3].AsString;
idp:=dbgrid2.DataSource.DataSet.Fields[4].AsString;
sql:='update kasir_opname_detail set kode='+quotedstr(kode)+',
jumlah='+quotedstr(jlh)+' where ptlokasi='+quotedstr(ptlok)+' and
tanggal=to_date('+quotedstr(after)+','+quotedstr('dd-mm-yyyy')+')'+' and
idpay='+quotedstr(idp)+'';
sqla:=sql;
zquery13.close;
zquery13.sql.clear;
zquery13.sql.add(sqla);
zquery13.execsql;
dbgrid2.DataSource.dataset.Next;
showmessage(sqla);
//end;
label19.Caption:=sqla;
end;
showmessage('Data Berhasil Disimpan!');
end;
However the data aren't saved as expected. it will only read last line of DBGRID then updates all data with values from last line of DBGRID.
is there something wrong with the code?
(prev it works with different dbgrid)
I am using delphi 7 and oracle as database. Thanks in advance.
Related
I am processing 1k record however I get system violation error after 800 record. Could someone please suggest how can this error be resolved?
There are designated methods for using OQL, you should take care to
Use a cursor variable
Declare a size that makes sense for your query
Open the cursor (allocates memory)
Close the cursor (disposes memory)
procedure ShowMoviesInCategory(theCategory : tCategory)
var Curs : aOQLCursor
var curMovie : aMovie
Curs = Motor.OpenOQLCursor
Curs.BatchSize = 50
OQL select * from x in aMovie++ where x.Category = theCategory using Curs
forEach curMovie in Curs
WriteLn(curMovie)
endFor
Motor.CloseOQLCursor(Curs)
endProc
Please also refer to the eWAM Help under OQL and
wTECH 101 (week1 - day 5 "101A - OQL - Search.pptx"
In Wynsure there is a designated variable for this, please refer to the Wynsure Development Rules.docx
I have a client that wants to be able to pick several things off the Silverstripe tag cloud widget.
So, using jQuery, I prepare a string containing all the selected tags which I then pass to a Silverstripe function.
if($_GET["selectedTags"]){
$selectedTagString = $_GET["selectedTags"];
$selectedTagString = substr($selectedTagString, 0, strlen($selectedTagString) -1);
$tagArray = explode("|", $selectedTagString);
$blogEntries = DataObject::get("BlogEntry")->filter(array("Tags:PartialMatch" => $tagArray));
return $blogEntries->renderWith(array("blogSearchResults"));
}
}
And it works quite well.
EXCEPT for tags that have an "&" in them, like "Otago & Southland", where the search fails and nothing is retrieved.
Looking at the generated SQL, everything seems to be fine.
SELECT DISTINCT "SiteTree_Live"."ClassName", "SiteTree_Live"."Created",
.
.
.
"BlogEntry_Live"."BlogEntryThumbnailID", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE 'SiteTree' END AS "RecordClassName" FROM "SiteTree_Live" LEFT JOIN "Page_Live" ON "Page_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "BlogEntry_Live" ON "BlogEntry_Live"."ID" = "SiteTree_Live"."ID" WHERE ("BlogEntry_Live"."Tags" LIKE '%southland & otago championships%') AND ("SiteTree_Live"."ClassName" IN ('BlogEntry')) ORDER BY "SiteTree_Live"."Sort" ASC
Has anyone had this problem before?
Are the tags stored using & in the db? Then you first should html encode your string.
I started using Overbyte components , used to use Indy but blocking issue made me look for something else , so I found ICS , but in this example code:
HTTPAsync
It creates new HTTPCli component for every link inside listbox , but when I change code a bit:
procedure THttpAsyForm.HttpCli1DocData(Sender: TObject; Buffer: Pointer;
Len: Integer);
var
AHttpCli : THttpCli;
begin
if not DataCheckBox.Checked then
Exit;
AHttpCli := Sender as THttpCli;
{ Display a message stating that data is available }
DisplayMemo.Lines.Add('Item ' + IntToStr(AHttpCli.Tag) + ' Data');
{ We could display the data, but it use a huge space in the display }
DisplayMemo.Lines.Add(StrPas(Buffer));
if something then <--- CODE I ADDED
ListBox1.items.add(AHttpCli.URL); <--- CODE I ADDED
{ We could also store the data somewhere (with the help of OnDocBegin }
{ and OnDocEnd events. Or using the RcvdStream property. }
end;
When I put 10 links it sometimes adds duplicates to listbox , or with one link it adds two same links to listbox .
How can I fix it to not show duplicates.My idea was to put it inside tstringlist and check for duplicates and remove them.
Is there any other way.Thanks
You can check to see if it already exists before adding it:
if something then
if ListBox1.Items.IndexOf(AHttpCli.URL) = -1 then
ListBox1.items.add(AHttpCli.URL);
Is there any tool I can use to perform pseudolocalization on an ASP.NET MVC app (using the Razor view engine) in order to help localizability testing?
i wrote a small utility app that lets me convert text into "pseudo".
It's based on a simple function which looks at each character in the string. If the character IsAlpha then i add an accent to it.
i add an accent by appending the character with a random diacritic mark between U+0300 and U+036F (the diacritical marks range).
So now i just localize my application/web-site like i were one of the dutch speaking localizers.
ỉ w͝rͨo͡t̮e̤ a͈͟ s̏m͈a͞l̪lͅ u͇t̽i̡l̔i͜țy̭ a͟p̉p͕ t̼h̥aͤt̖͊ l͊e̗t̘s̈́
m̶eͭ c͟o̙n̚v̈e̲r̓t̝ t͌e̽x̳t͈ i̍n̔t̖o̺ "p̪̜s̔e̊u̟d̮o̱".
I͔t͒'sͪ b̞aͧs̜e̋dͫ o̸͚n͙ a̼ s̼i̥m̢ͫpͫl͗e̺ f̙uͪn͎̉c͙t͒ḯo̾n̑ w̰h̙i̷c͟ḣ̌
l̼óoͦk͔s͑ a̬t̆ e̓a̔c̈hͭ c̚h̻a̿r̴aͭc̤t̙eͦŗ͉ i̞n̴ t̀h̸e̮ͫ s̖t͘r͕i͇n͒g̴͐.
I̳fͣ t̰ĥe̿ c͋h͡a͖r̸a̸c̟t̼e̞rͪ Ìs̀A̒l͒p̷h̗a̲ ţh̽e͚nͥ i̡ a̰d͙d̬
a̅n̊ a̐c̒c̒e̤͞n̜t̽ t̆o͑ i̴tͪ.
i̋ a̸d̋d́ a̰n̏ a͛c͏c̣͗e̾n͡t̎ b̷̞ẏ a̐p͞p̧͔eͩn͊ḍ͋ín̓g͚ t̬h͚ẹ
ćh̞a͗ŗa͖c͐t̊e̷rͅ w͙iͩt̮hͮ a͡ r͙a͋nͅd̃o͞m̚ dͬi̠a͚c̸r̾iͩt͖i͋c̭ m̓ḁr̵k̡
b̞ë́t̼w̓e̬ë́n̨ U̵+0300 a̢n͙d͜ U͕+036F͓ (t̯͉hͪ͟eͮ
d͓i͉aͣc͕̬r͜i͒t́i͓c̯a͚l̼ m̓a̅r̝̜k͎s̯ r͋ăn̪̒g̟e̱̮).
There's also an option to add padding to text, so allow for other languages not using the same amount of space as english
Today -> [T̀oͨd̼a͈̹y̭ !!]
Control Panel -> [C̊ȍńt̪r͗o͂l͇ P̈ȁñeͮl͢ !!!!!]
Oxydative Decarboxilation -> [Ŏx͞y̠dͥa͂t̿i̚v͙eͪ D̼e̖c̿aͤr͖b̐o̼x̹i͂l͖a̠t̮i̓o̧n̰ !!!!!!!!!]
And my PsuedoLocalizeText function:
function TForm1.PsuedoLocalizeText(s: WideString; AddPadding: Boolean): WideString;
var
i: Integer;
sb: TWideStringBuilder;
x: Integer;
tiny: WideString;
const
n: WideString = ''; //n=nothing
begin
//Code is public domain. No attribution required.
sb := TWideStringBuilder.Create;
try
for i := 1 to Length(s) do
begin
//http://www.fileformat.info/info/unicode/block/combining_diacritical_marks/list.htm
//U+0300 .. U+36F are combining diacritic marks
x := $300+Random($36f-$300);
if Windows.IsCharAlphaW(s[i]) then
begin
tiny := n+ s[i] + WideChar(x);
if Random(10) < 1 then
tiny := n+tiny+WideChar($300+Random($36f-$300));
sb.Append(tiny);
end
else
sb.Append(s[i]);
end;
Result := sb.ToString;
finally
sb.Free;
end;
if AddPadding then
begin
Result := '['+Result+' ';
for i := 1 to Ceil(Length(s) / 3) do
begin
Result := n+Result+'!';
end;
Result := Result+']';
end;
end;
Update My psuedolocalizer:
My next task is to have it work on *.resx, but exclude *.xx-yy.resx, so it can work on WinForms applications as well.
And of course fill in Size, Attributes, get the right icon for Folders.
Then maybe have it highlight the fr-FR or qps-ploc part of filenames.
There is a "pseudoizer" tool in the downloads for this article: http://msdn.microsoft.com/en-us/magazine/cc163991.aspx
It includes both source (winforms) and binary if you're lazy
After not finding anything quick, free and easy, I built Pseudolocalize.com! Just copy/paste/click and you've got the pseudolocalized version of your strings!
I am getting nil value when I tried to update the data for below code :
local update_statement =db:prepare[[ UPDATE list SET :name :icon WHERE :id]]
update_statement:bind_names{ name = aName, icon = aIcon, id = aId }
update_statement:step()
update_statement:reset()
And also I need the syntax for delete operation in lua program.
Please help me
Thank you,
Madan mohan.
You need to learn SQL's syntax.
Basically, you're not telling which columns you want to update, you're only giving their values.
local update_statement = db:prepare[[ UPDATE list SET name = :name, icon = :icon WHERE id = :id]]
Here's the syntax for the DELETE statement:
local delete_statement = db:prepare[[ DELETE FROM list WHERE id = :id]]