Solved

Need help in Database (TDataSet)

Posted on 2002-04-14
17
217 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

16 Experts available now in Live!

Get 1:1 Help Now