Hi all,
I have a database and i have deleted a record.
Suppose
I have records 1,2,3,4,5,6,7
And i delete no 5 now my record will appear 1,2,3,4,6,7
But i want to rearrange them by 1,2,3,4,5,6
Thanx
15 1821
just arrange them in number order then go back to the beginning, start from 1 and re-number them from 1 to x until you get to the end of the records. Are you using a data control with a db? .. if so ill chuck up an example
just arrange them in number order then go back to the beginning, start from 1 and re-number them from 1 to x until you get to the end of the records. Are you using a data control with a db? .. if so ill chuck up an example
Thanx
But can you give me an example how can i do this .
I m using vb6 and ADODC
thanx
Assuming a couple of things ... -
-
'Delete the record you want then ...
-
dim cc as integer
-
dim SQL as string
-
-
SQL = "SELECT * FROM tablename ORDER BY fieldname ASC"
-
datdata.recordsource = SQL
-
datdata.refresh
-
-
for i = 1 to datdata.recordset.recordcount
-
cc = cc + 1
-
datdata.recordset.edit
-
datdata.recordset!fieldname = cc
-
datdata.recordset.update
-
datdata.recordset.movenext
-
next i
-
-
Hello,
That will do changing, but be sure that it wont affect the other records.
In long Run, when your Database has may Records and do Re-numbered, you've got what i mean.
Hello,
That will do changing, but be sure that it wont affect the other records.
In long Run, when your Database has may Records and do Re-numbered, you've got what i mean.
It would effect on other records.
Because my app is a school DataBase system. And all the regestration forms are saved withe the originals but when i delete then it wil clash with the regestration form enteries.
I m doing this because my database assigns the rollno and regno automatically by using this code.
ADATA.Refresh
txtREG.Text = ADATA.Recordset.RecordCount + 1
ADATA1.Refresh
txtROLL.Text = ADATA1.Recordset.RecordCount + 1
Hello,
That will do changing, but be sure that it wont affect the other records.
In long Run, when your Database has may Records and do Re-numbered, you've got what i mean.
It would effect on other records.
Because my app is a school DataBase system. And all the regestration forms are saved withe the originals but when i delete then it wil clash with the regestration form enteries.
I m doing this because my database assigns the rollno and regno automatically by using this code. - ADATA.Refresh
-
txtREG.Text = ADATA.Recordset.RecordCount + 1
-
ADATA1.Refresh
-
txtROLL.Text = ADATA1.Recordset.RecordCount + 1
Have you any other code to assigning the roll and reg.
suppose i have records
1,2,3,4,5,6
if i delete a student which is rolled 5 .
By using my code when we add a student after deleting it will assign 6 to the new student but there is also a student rolled 6. Now it will make duplicate items and occurs error because roll is primary.
Can you solve this problem.
Thanx
It would effect on other records.
Because my app is a school DataBase system. And all the regestration forms are saved withe the originals but when i delete then it wil clash with the regestration form enteries.
I m doing this because my database assigns the rollno and regno automatically by using this code.
ADATA.Refresh
txtREG.Text = ADATA.Recordset.RecordCount + 1
ADATA1.Refresh
txtROLL.Text = ADATA1.Recordset.RecordCount + 1
Well, Its up to you.
You delete the primary then it affect the foreign key and the records connected to the primary key.
Well, Its up to you.
You delete the primary then it affect the foreign key and the records connected to the primary key.
The question is How can i assign roll automatically with no logicall error.
Plz help.
The question is How can i assign roll automatically with no logicall error.
Plz help.
Please let me know your tables, and what is the relation between your "Roll" and "Regno".?
Please let me know your tables, and what is the relation between your "Roll" and "Regno".?
Ok
forget about reg no.
I have a table named one (class one). in this table all students studying in class one are kept. Columns are RollNo, Name, Father;s Name.
Roll no has primary key.So that it cannot be duplicate.
I want to assign rollno of new student automatically.
Thanx
Ok
forget about reg no.
I have a table named one (class one). in this table all students studying in class one are kept. Columns are RollNo, Name, Father;s Name.
Roll no has primary key.So that it cannot be duplicate.
I want to assign rollno of new student automatically.
Thanx
Your Rollno is your primary key, right?
ley say you have Records like
RollNo Name Address
1 Ervin Philipines
2 Jay-ar Philipines
3 Peter Philipines
4 Paul Philipines
WHERE RollNo is the Primary key.
Now, you delete Record RollNo(3) Name(Peter) Paul(Philipines)
Now the Records will be
RollNo Name Address
1 Ervin Philipines
2 Jay-ar Philipines
4 Paul Philipines
for that, you cant change RollNo(4) to RollNo(3) because its a primary key.
in short you cant Re-number the primary key...
if you delete all that record then the next record will be RollNo(5).
This is just my opinion for now, i dont if its really is.
And one thing, re-numbering for me is not advisable.
Why? let say you have thousand of records, then i delete record number 2 and you do renumbering by used of Looping, then it will do Loop thousand times.
the question is, IS your System are Strong enough to Loop thousand times?
Regards
Ervin
Why? let say you have thousand of records, then i delete record number 2 and you do renumbering by used of Looping, then it will do Loop thousand times.
the question is, IS your System are Strong enough to Loop thousand times?
Regards
Ervin
Mine is but the person to whom for i m makeing is not too musch powerfull so that it ll be loop for thousand times.
If i move to the last record and then add 1 to the last record to make new entry it ll make sense but sometimes database sort the files
1
10
2
3
4
5
6
7
8
9
and if do then it will make entry with Sr 10 which is already made.
How can i avoid such error.
One thing more if i use a code which finds the biggest number in the data and then made entry by adding 1 in the entry.
Hows the idea.
If yes then plz tell me how can i found the biggest no.
Thanx
Ervin
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
use this query:
Select Max(Val(RollNo)) As MaxRollNo From MyTable
Provided, RollNo does not contain any varchar value..
REgards
Veena
Mine is but the person to whom for i m makeing is not too musch powerfull so that it ll be loop for thousand times.
If i move to the last record and then add 1 to the last record to make new entry it ll make sense but sometimes database sort the files
1
10
2
3
4
5
6
7
8
9
and if do then it will make entry with Sr 10 which is already made.
How can i avoid such error.
One thing more if i use a code which finds the biggest number in the data and then made entry by adding 1 in the entry.
Hows the idea.
If yes then plz tell me how can i found the biggest no.
Thanx
Ervin
To arrange:
Select RollNo, Name, FathersName From MyTable ORDER BY RollNo ASC
To choose the biggest number:
just read post reply of QVeen
Regards
Ervin
Hi,
use this query:
Select Max(Val(RollNo)) As MaxRollNo From MyTable
Provided, RollNo does not contain any varchar value..
REgards
Veena
Hello,
Thanks Veena
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Philip Boonzaaier |
last post by:
I want to be able to generate SQL statements that will go through a list of
data, effectively row by row, enquire on the database if this exists in the
selected table- If it exists, then the colums must be UPDATED, if not, they
must be INSERTED.
Logically then, I would like to SELECT * FROM <TABLE>
WHERE ....<Values entered here>, and then...
|
by: Robert Schneider |
last post by:
Hi to all,
I don't understand that: I try to delete a record via JDBC. But I always
get the error SQL7008 with the error code 3. It seems that this has
something to do with journaling, since the table from which I want to
delete has two foreign keys that references two other tables and it is
also referenced by another table. But this...
|
by: Steve |
last post by:
I have several pairs of synchronized subforms in an application. I have a Delete
button for each pair that uses the following code or similar to delete a record
in the second subform:
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
End If
ExitHere:
Me!SubName.SetFocus
|
by: John Rivers |
last post by:
Hello,
I think this will apply to alot of web applications:
users want the ability to delete a record in table x
this record is related to records in other tables
and those to others in other tables etc.
in other words we must use cascade delete to do
|
by: Bob Bridges |
last post by:
Start with two tables, parent records in one and child records in the other,
a one-to-many relationship. Create a select statement joining the two.
Display the query in datasheet mode. When I delete a row, only the child
record is deleted from the source tables; the parent record is still
there...which is what I wanted.
Now display fields...
| |
by: sh26 |
last post by:
I can Add and Delete (A, CName, MX and TXT) Dns records on the Dns Server using C# code. The problem I am having is if someone manaully creates a TXT record on the Dns Server, I cannot delete that particular record using the same C# code. Here is what I am using to delete the records:
public void DeleteRecord(string domain, string recordName,...
|
by: Phil Stanton |
last post by:
I have a form based on a complex query (Lots of tables)
If I delete a record, everything appears to be OK. Get the message "Youa are
about to delete 1 record ....". I say yes. The record count goes down
correctly. Then if I do Records-->Remove Filter/Sort there are the deleted
records back as if they had never been deleted. Same thin exactly...
|
by: kcdoell |
last post by:
Hello I have a code where I want to delete the records that are found in my DAO recordset. I took a stab at this for the first time and got it to work but it is only delete one record at a time. If I execute the code again my record count will be minus one and then it will delete another single record etc etc until there are no records to...
|
by: WyvsEyeView |
last post by:
Upon clicking Delete to delete the current record on frmTopics, I want several things to happen:
1) Display a custom message rather than Access's standard "You are about to delete n records" one.
2) Delete the record.
3) Delete all related attribute records.
4) Go to a new record.
Here is my code:
Private Sub cmdDelete_Click()
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |