Solved

Need help in Database (TDataSet)

Posted on 2002-04-14
17
215 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
 

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

759 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

21 Experts available now in Live!

Get 1:1 Help Now