Solved

Need help in Database (TDataSet)

Posted on 2002-04-14
17
221 Views
Last Modified: 2012-05-04
Hi,

This is my problem:
1) When I click Edit button to edit the current data in the table and then I cancel it and I browse a while other data, why did the application have an exception when I click the edit button again? What I know, it shouldnt happen that way. It should be allright.
2) I want to do like this... Data <num> of <10>... coz there is 10 record count. but how about the <num> part. I can't use RecNo to make it happen. What other option could I do?
3) How to search a certain text in table so it can be display in list?

Hope you understand my language and my question.

iqmedia
0
Comment
Question by:iqmedia
  • 7
  • 3
  • 3
  • +3
17 Comments
 
LVL 9

Expert Comment

by:ginsonic
ID: 6940114
listening
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6940119
what database do you use?
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6940915
listening... don't really understand :)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:Patranjali
ID: 6942193
Hi,
I am not very sure that I have understood your whole question correctly.But I can give u some idea from teh parts I understood.
For the recno part,try using a Query object and add a 'select count(*) from...' statement to it.Store that val in an integer variable and use this in  a loop as ur counter in  'Data <num> of <10>... '.
The other thing about searching for the text , u could try in 2 ways.
1.using  a select statement ,with the 'like % ' parameter
or
2.using locate() function of Delphi.

What Exception did u get when u ttried to edit?

See if you understand what I have written.

Thanks,
Pat
0
 

Author Comment

by:iqmedia
ID: 6942331
Ok... I'm using MSAccess.
In my app. I want it to show to user number of record for the current database.
Example: Record 1 of 10. If you click next button it will show Record 2 of 10. If you delete the 5th record it will be like this.. 1,2,3,4,6,7,8,9,10 but when you browse the 6th record I want it to show Record 5 of 10 not Record 6 of 10.

The exception that I receive is General SQL error. Wrong number of parameter.

Thank Patranjali. If you can answer this, the points is yours.

iqmedia
0
 

Author Comment

by:iqmedia
ID: 6942338
Ok... I'm using MSAccess.
In my app. I want it to show to user number of record for the current database.
Example: Record 1 of 10. If you click next button it will show Record 2 of 10. If you delete the 5th record it will be like this.. 1,2,3,4,6,7,8,9,10 but when you browse the 6th record I want it to show Record 5 of 10 not Record 6 of 10.

The exception that I receive is General SQL error. Wrong number of parameter.

Thank Patranjali. If you can answer this, the points is yours.

iqmedia
0
 
LVL 14

Accepted Solution

by:
DragonSlayer earned 300 total points
ID: 6943634
I suppose you are using ADO? From the help file

TCustomADODataSet.RecNo

The dataset must be active for RecNo to have a valid value. When a dataset component is active, RecNo will be a number between one and the total number of rows in the recordset (reflected in the RecordCount property).

Sample of an event handler in the AfterScroll event of the dataset:

StatusBar1.Panels[0].Text := 'Record ' + IntToStr(TCustomADODataSet(DataSet).RecNo) + ' of ' + IntToStr(TCustomADODataSet(DataSet).RecordCount);


HTH
DragonSlayer
0
 

Author Comment

by:iqmedia
ID: 6943954
The error came out when I do this:
First I click the edit button so the state is dsEdit.
Then I cancel it so the state is dsBrowse.
Then I click next or previous button just for fun.
Then I click the edit button again and this where the error came out.

Thanks DragonSlayer. I'll try it first...

iqmedia
0
 

Expert Comment

by:TomazB
ID: 6945848
listening
0
 

Author Comment

by:iqmedia
ID: 6947011
Hi,

Still no improvement than the last one DragonSlayer. I've try your approach.
This are the error:
General SQL error. Wrong number of parameters.

New on this error!
This error came out when you also doing this,
1) Click edit and cancel it for 3 times...

Anyone can help me on this? and the RecNo..?

iqmedia
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6947015
you need an unique index on your table,
do you have an unique index ?
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6947038
iqmedia, you are sure that the problem arises from the execution of RecNo, and not on stuff before that?
0
 

Author Comment

by:iqmedia
ID: 6947891
The error are not from the exec of RecNo....
I have 3 things:
1) The RecNo
2) The error
3) The searching

iqmedia
0
 

Author Comment

by:iqmedia
ID: 6947897
kretzschmar,

the unique index are for what things as above i mention...?

iqmedia
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6947934
its needed for relocating
the databasecursor
to the correct record

guessing you get the error,
because your app is unable
to relocate

meikl ;-)
0
 

Expert Comment

by:Patranjali
ID: 6948011
listening ..
Pat
0
 

Author Comment

by:iqmedia
ID: 6948182
Hmm... hard to understand and hard to create even maybe a simple function... maybe...

iqmedia
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
code issue 8 177
Delphi XE7 Firemonkey - text turns black after tabbing between applications on android 5 72
shape, triangle, dbctrlgrid 3 31
Broadcast a message using ICS 2 20
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question