Updating data through Transaction Control

daves

Member
Joined
Jun 30, 2006
Messages
19
Programming Experience
10+
Hi,

I want to write a program not not use the default behaviour of ADO.NET and datasets.

What I'd like to do is to have a combo box at the top of the form that a user could use to select a record out of the database. The form would fetch the data and lock the record and then the user would save the changes back to the database.

Does anyone have any sample app's like this?

The database would be SQL Server.

Thank you,

Dave
 
What I'd like to do is to have a combo box at the top of the form that a user could use to select a record out of the database. The form would fetch the data and lock the record and then the user would save the changes back to the database.

First note. I have worked on many SQL server systems and to date all of them have been disconnected datasets, by this I mean that you fetch the data, then send the updates back. In order to determine if your row has been changed, you would have to have a field of type TimeStamp in your database table and compare the values from when you read the data in preparation to modify to when you submit your update to be saved. Each time a row is updated this field gets a new value, if the values are the same between when you read the record and when you write it, no updates have occurred to the data and you can write your data. Of course, you can also create a field of type BIT called LOCKED and prevent your apps from allowing a read that is a precursor to update from occurring but then you are letting your app do the job that the database was designed to do. Please do not confuse TimeStamp in SQL Server with TimeStamp in MySQL, they are different. Microsoft kinda got it wrong when they named TimeStamp since the ANSI standard uses that type for something else entirely. Think of TimeStamp as the version of the row in question, each time the row gets changed, its version changes.

On to your question, I am sure that many of us could provide a sample app that does what you request. All of my code uses ample use of datasets and stored procedures and your post specifically mentioned avoiding this and since your only option at that point is to use datawriter and datareader classes and make your data engine a connected engine rather than disconnected and I personally have no code like that.

If you want a sample slice of code that will show you the CRUD for a single table from the stored procedures on up to the Controller I will provide it. Just paste in the Create Statement for the database table you wish to have the slice for and I will generate it for you. My code generator does not handle TimeStamp as listed above since I wrote that generator back before I had an understanding of what TimeStamp really was so I will not be able to demo that particular concept in code for you at this time (I am still researching TimeStamp and working on my first db that uses it).

I await your reply.
Cheers.
 
Thank you. I've been doing allot of research lately. Would you have a sample with datasets but not with stored procedures?

Thanks
 
Back
Top