Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to order by branch?

Status
Not open for further replies.

fbbilalli

Technical User
Sep 6, 2008
1
MK
Hi all, whaz up

poeple i have a little problem!
if anybody could help me, i would be grateful


i have made an application in borland c++ about credit cards
there are 2 fields, and between them are 2 buttons (import and status)
when i press the import button, i choose the place from where i wanna get
the files in the first field.
Only specific files can be imported (PAN's - long numbers)
so when the numbers are on the first field, i have to press the second
button the satus button, so the PAN's would go to the other field
but ordered by min/max value.
In the first field they are ordered from the minimum to the maximum.

So where is the problem you ask? Well i wanna put this code:

select ncrd,tcrnacrd, nbrn from =gcard where ncrd in
("6770320004869316",
"6770320004870710",
"6770320004873417",
"6770320004873516") - EXAMPLES of PAN's

order by PAN_INDEX_RANGE_ID, NBRN, NCRD;


into the main code, or somewhere there, so i can order the PAN's in the
SECOND field by NBRN - branches.
Could anybody help me.
Here is the main code:

if(fileRecCount<1)
{
ShowMessage("No records");
return;
}
PinPrintControl->BeginTrans();
dbRecCount =0;
int errRows = 0;
AnsiString tmpStr;

statusGrid->Cols[0]->Clear();
statusGrid->Cols[1]->Clear();
int row=0;
int a=0;
statusGrid->RowCount=0;

for (int i=0; i<cardsGrid->RowCount; i++)
{
PinQuery->Active = false;
PinQuery->SQL->Clear();
tmpStr="SELECT ncrd, cisspcrd FROM GCARD WHERE";
tmpStr = tmpStr + " ncrd = '" + cardsGrid->Cells[0] + "'";
PinQuery->SQL->Add(tmpStr);
PinQuery->Active = true;
PinQuery->First();

if (!(PinQuery->Eof && PinQuery->Bof))
{
dbRecCount++;
statusGrid->Cells[1][row] = PinQuery->FieldByName("cisspcrd")->AsString;
statusGrid->Cells[0][row] = PinQuery->FieldByName("ncrd")->AsString.Trim();

if (statusGrid->Cells[0][row]!="")
{
statusGrid->Refresh();
row++;
statusGrid->RowCount++;
}
else
{
statusGrid->RowCount--;
row--;
statusGrid->Refresh();
}
}
else if (PinQuery->Eof && PinQuery->Bof)
{
statusGrid->Cells[0][row] = "There is not such a PAN!!";

if (statusGrid->Cells[0][row]!="")
{
statusGrid->Refresh();
statusGrid->RowCount++;
row++;
}
else
{
statusGrid->RowCount--;
row--;
statusGrid->Refresh();
}
}
}

statusGrid->RowCount = row;
status->Panels->Items[2]->Text = "Numbers of cards in base: " + IntToStr(dbRecCount);
status->Panels->Items[1]->Text = "Mistakes: " + IntToStr(errRows);

if(fileRecCount==dbRecCount)
{
minRow->Enabled=true;
maxRow->Enabled=true;
minRow->MaxValue = statusGrid->RowCount+1;
maxRow->MaxValue = statusGrid->RowCount;
}else
{
minRow->Enabled=false;
maxRow->Enabled=false;
minRow->MaxValue = 1;
maxRow->MaxValue = 0;
ShowMessage("different numbers of cards in the base and in R*");
}

PinQuery->Active = false;
PinPrintControl->CommitTrans();

---------------------------------------------------------------
Anybody, please

thanks
best regards
 
Code:
 tmpStr="SELECT ncrd, cisspcrd FROM GCARD WHERE";
        tmpStr = tmpStr + " ncrd = '" + cardsGrid->Cells[0][i] + "'";
        tmpStr += " order by PAN_INDEX_RANGE_ID, NBRN, NCRD;" // This is equivalent to tmpStr = tmpStr + ....

That ought to work. I'm doing this from memory so it may be "faulty." Another way to do this is to pull the data into a dataset and sort it there. The advantage is that the dataset will be local and not on the server. The disadvantage is it could be slower depending on the server and client.


James P. Cottingham
-----------------------------------------
I'm number 1,229!
I'm number 1,229!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top