Solved

Need help in Database (TDataSet)

Posted on 2002-04-14
17
218 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TVirtualStringTree  search using TEdit 7 119
Delphi cmd execution 6 60
HTML text in the body of an email (delphi code) 12 112
Breakpoint doesn't stop in my variable 3 23
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

815 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now