Hello!!
I am working on an application in which i have to save the name of members of a group to another table other then the main table(as normalization is done ) .
Now i am using sql transactions to save the names into table.
The table structure of two tables are
For VisitorPass Table
unqid || PassNo || PassType || VisitorName || ToMeet || Department
and some other fields
For GroupMember Table
unqid || PassNo || GroupMemberName
Now i have two stored procedures to enter data into these tables. In may Class file i have made functions which return String values from cmd.ExecuteNonQuery.ToString() (0 or 1)
Now if the passType is Group the i will have to save the names of members in GroupMembers Table.
I have done it upto here
objMem.unqid = Convert.ToInt64(0);
objMem.Passno = Convert.ToInt64(txtPassNo.Text);
for (int i = 1; i<=Name.Count;i++ )
{
objMem.Visitorname = Name[1];
con.Open();
trns = con.BeginTransaction();
y = objMem.fnSaveGroupMembers(trns);
}
What i need to know is can i commit the transaction out of the foreach Loop and if so will it save all the name or just the last one? I will be saving data in both the tables if pass types is group so the transactions should commit only if both the tables get data.
Or can you suggest some other approach that i should try ???