ChoKamir Posted June 26, 2006 Posted June 26, 2006 Hey, First of all i work with an access database. In my program i made an DataAdapter with retrieves rows from the database from two tables(through an inner join). Because the dataset linked to this DataAdapter is represented in a datagridview i also wrote insert, delete and update commands. The way i solved the insert in two tables is with an transaction. In the RowUpdating event of the DataAdapter i create an transaction and manually insert the row in one of the tables. The insertcommand of the dataadapter will handle the insert in the other table. In the RowUpdated event of the dataadapter i commit the transaction. This works all fine, except for the fact that some values in the datagrid are left empty because then the default values will be inserted and there is a column with a expression (calculating the product of two columns of a row). Now the default values won't appear nor will the column with the expression show a value. The reason for this is that the inserted data into the database is not returned to the dataset. So how can i make sure that the actual data of the inserted row in the database is reflected to the dataset? Thanks for helping ChoKamir Quote
Administrators PlausiblyDamp Posted June 26, 2006 Administrators Posted June 26, 2006 You could just SELECT the results back into the dataset after your insert / update / delete has occurred. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
ChoKamir Posted June 26, 2006 Author Posted June 26, 2006 You could just SELECT the results back into the dataset after your insert / update / delete has occurred. Thanks for your answer, although i was hoping for an easier method. Because how i interpreted your answer is: In the RowUpdated event i execute a command selecting the newly inserted row. I loop through the columns in the datareader and set them to the row by e.Row.ItemArray.SetValue(reader,i). Although what ever i trie this function SetValue returns: Expression has been evaluated and has no value. Also when i user e.Row.ItemArray[2] = 0. No matter what i try it doesn't store the values. What am i doing wrong now? Thanks 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.