Refresh data from database
Hello,
Is there a way to refresh the data of a form after insertion? At insert the database fills some fields automatically for the user and i want the user to view them automatically after the insertion of the record.
Thank you.
DealyPosted Aug 30, 2009, 10:25 AM
After a little research in the subject I decided to use output variable in the Stored Procedure in order to avoid the reselection.
Below i give the code snippet for stored procedure and C#, using Northwind as a database.
Stored procedure:
C# code:
Kirtan PatelPosted Aug 28, 2009, 9:15 AM
yes, this will make but there is no other option .
because you have updated/Inserted record in database you have to reconnect to server to get latest data to dataGridView. think that insertion operations are not performed as frequently as deletion and Updation done !! so its considerable.
in case of Filter you should not use this type of strategy you can directly filter data from already filled data set :)
dont forget to mark "do you like answer please it will give me some credits :)
DealyPosted Aug 28, 2009, 9:03 AM
Kirtan PatelPosted Aug 28, 2009, 7:33 AM
you should make function to Show Data into DataGridView
like
-------------------------------------------------------------------------------------------
public void ShowData()
{
// Coding for Showing Data In DataGridView
}
now when you press Insert Button say Button1
then Code Would be like below
public void Button1_Click(Object Sender , EventArgs e)
{
//Code for Inserting Details into database
//Below Show Data Function Will Automatically Refresh The DataGridView
ShowData();
}
----------------------------------------------------------------------------------------------------------
dont forget to mark "Do you like answer" please it will give me some credits :)