Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-30-2004, 06:06 AM   #1 (permalink)
Epohrolias
Registered User
 
Join Date: Jul 2004
Posts: 2
Epohrolias is on a distinguished road
DBgrid problem!

Hi Everybody,

First, sorry for my english...

I'm using a DBgrid.

The options are the following :

[dgTitles,dgColumnResize,dgColLines,dgRowLines,dgRo wSelect,dgConfirmDelete,dgCancelOnExit,dgMultiSele ct]

I'm trying to test if I find the record I select with this code (in a Button) :

Code:
bool record_found = false;

while(!DM->Query->Eof && !bool record_found)
{
     if(DBGrid->SelectedRows->CurrentRowSelected)
        {
            bool record_found = true;
        }
        DM->Query->Next();
}
(Query is the query object attached to the DBgrid)

But when I select the first row, that don't work...

I tried many thing since 2 hours and nothing seem to work : everytime, the first row don't seem to exist when I select it manually or not... (all other rows work propely)

Do anybody have a solution for this problem?

Thanks a lot...

Epoh

P.S. When I put the indicator to true, the "->" color is different when it's the first row...

P.S. I tried also "DBGrid->SelectedRows->Delete();" for deleting and even if I select only 1 row it delete ALL rows even if the "DBGrid->SelectedRows->Count" indicate that I selected only 1 row... Do these objects work propely or did I forget to do something?

Last edited by Epohrolias; 07-30-2004 at 07:04 AM.
Epohrolias is offline   Reply With Quote
Old 08-01-2004, 10:39 PM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,696
redhead is on a distinguished road
Quote:
I'm trying to test if I find the record I select with this code (in a Button) :
Code:
bool record_found = false;

while(!DM->Query->Eof && !bool record_found)
{
     if(DBGrid->SelectedRows->CurrentRowSelected)
        {
            bool record_found = true;
        }
        DM->Query->Next();
}
Everytime, the first row don't seem to exist when I select it manually or not...
Looks like you're creating several instances of the record_found here, have you tried:
Code:
bool record_found = false;

while(!DM->Query->Eof && !record_found)
{
     if(DBGrid->SelectedRows->CurrentRowSelected)
        {
            record_found = true;
        }
        DM->Query->Next();
}
Since within the while loop the bool record_found will create a new instance of record_found that resides in the while scope, and won't intervene with the record_found declared outside the while scope.
Quote:
P.S. When I put the indicator to true, the "->" color is different when it's the first row...
What are you talking about?? a color changing when setting something to true, are you talking about the IDE you're developing in??
Quote:
P.S. I tried also "DBGrid->SelectedRows->Delete();" for deleting and even if I select only 1 row it delete ALL rows even if the "DBGrid->SelectedRows->Count" indicate that I selected only 1 row... Do these objects work propely or did I forget to do something?
It depends, if you have a flaw in your while loop, which makes it keep on going, then every row will eventualy be deleted.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 08-02-2004, 04:11 AM   #3 (permalink)
Epohrolias
Registered User
 
Join Date: Jul 2004
Posts: 2
Epohrolias is on a distinguished road
Thanks but that don't work anyway... I think I will forget BDGrid, that's too difficult to explain the problem when we don't see what's exactly the problem is...

(the "bool" in front of the "record_found" was not here in the original program, that was just a typing error of my code in this forum...)

I asked all programmers where I work what they think the problem is and they all think that that's an error of the Borland C++ builder so I will try another object.

Thanks...
Epohrolias is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with editing profile cheawick Feedback 0 04-28-2004 10:26 PM
JavaScript Problem dawkim HTML, XML, Javascript, AJAX 2 01-26-2004 07:02 PM
Help debugging a power problem Belisarius Lounge 0 10-25-2003 04:44 PM
structure problem Goshi Standard C, C++ 5 04-21-2003 12:19 AM
This is a windows/C problem UnderWing Standard C, C++ 6 03-28-2003 06:17 AM


All times are GMT -8. The time now is 11:27 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting