Roey Posted October 26, 2004 Posted October 26, 2004 I have a dataset that I need to write to a database in a particular order. I realize that I can change the sort order of a dataview, but is there any way of controlling the order that the records are written to a database. Thanks in advance Quote
kejpa Posted October 27, 2004 Posted October 27, 2004 Why do you want to save the records in a particular order?!? Relying on records to be stored in a certain order is bad practice. Kejpa Quote
stustarz Posted October 27, 2004 Posted October 27, 2004 Despite what kejpa says, to give you an answer to your question, i would personally just have an extra column in the dataset holding an integer value - numbered 1 to whatever, you could use an order by clause or sort on this column. Just an idea! Quote Visit: VBSourceSeek - The VB.NET sourcecode library "A mere friend will agree with you, but a real friend will argue."
kejpa Posted October 27, 2004 Posted October 27, 2004 Despite what kejpa says' date=' to give you an answer to your question, i would personally just have an extra column in the dataset holding an integer value - numbered 1 to whatever, you could use an order by clause or sort on this column.[/quote'] To have an extra field with sort order is a good idea, I've never implied it's not. What IS a bad idea (this is my key point) is to rely on the order records are written to the database, when you compress an Access database the order might be different if you've done deletes and inserts to the table. Using other databases may cause similar problems. If it's necessary to retireve the records in a particular order, don't rely on the order they were written, use a sort order. That's my take on it. And that's why I can't understand why the order the records are written matters. /Kejpa Quote
Roey Posted October 27, 2004 Author Posted October 27, 2004 The order matters because I am getting data from one program in an order that I have no control of. I then have to process this data make some changes to it, and then sort it. The data is then inserted into a database and displayed in a second program that I have no control over. This program displays the records by the order that they are entered into the database. I realize that doing it this way is less than ideal, but this is the requirement I have been given...... That being said inside of my data processing program I can sort and display the records in a dataview that suits my needs. I just can't seem to get the records into the database in that order. Quote
kejpa Posted October 28, 2004 Posted October 28, 2004 The data is then inserted into a database and displayed in a second program that I have no control over. This program displays the records by the order that they are entered into the database. Alright, makes sense. However, if you have the other program to sort when it reads the database you'd be much happier ;) To be sure they're written in the correct order I guess you would have to write them one at a time to the database. Some databases ignore the order they're written and some don't. Let's just hope yours do :) HTH Kejpa Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.