Dear experts
I am following way for C#.NET Programs..Keeping in mind that many user will use program at a time
STEP 1 : Generate Unique Id from any table
STEP 2 : Generate transaction in following way
SqlConnection Con = new SqlConnection;
Con.BeginTransaction
STEP 3: My sql statements(Insert/Update/Delete)
STEP 4: Commit or Rollback
just need whether I should do any changes or not.Is the above way is good if there are more users using software at a time.
Regards
Mayur
Ramesh PalanivelPosted Mar 21, 2017, 1:28 AM
Nitin SontakkePosted Mar 21, 2017, 12:25 AM
Ibrahim SiddiquePosted Mar 20, 2017, 11:49 PM
Rathrola Prem KumarPosted Mar 20, 2017, 9:35 PM
Narasimha Reddy ChennupalliPosted Jun 26, 2015, 1:13 PM
SqlConnection conn = new SqlConnection(constring);
//Step 1: Open the Sql connection
conn.Open();
SqlCommand cmd = new SqlCommand("insert into moneytrans values(" + cmbuserid.SelectedItem.ToString() + "," + txtamount.Text + ")", conn);
//Step 2: Begin the transaction
SqlTransaction trans = conn.BeginTransaction();
cmd.Transaction = trans;
try
{
cmd.ExecuteNonQuery();
//Step 3: Commit the transaction
trans.Commit();
MessageBox.Show("Transaction Complted. ");
}
catch (Exception)
{
//Step 4: If anything happens Roll back the transaction
trans.Rollback();
MessageBox.Show("Transaction Failed..");
}
}
conn.Close();
I hope this will help you.