Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted
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

Posted

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.

Posted
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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...