I Have a Form which will send Data to Multiple Table on Single Click,
Person, Education, Experience, Reference.
How can i add Data into Multiple Table so All Have Same Person ID in them,
I am Newbie and using tier Architecture, all the Database code is in DAL,, ) Working with Asp 2.0
I am thinking to doing it with a Stored procedure of Inserting into Person and getting PersonID a output parameter, but i dont know how to use that output Parameter to insert into other Tables.
My Sample COde is This
public virtual bool AddJobApplication(int JobID, string Name, string FatherName, string Phone, string Email, string Address, int AppID)
{
obj_db2.objCmd.CommandText = "AddApplication";
obj_db2.objCmd.CommandType = CommandType.StoredProcedure;
obj_db2.objCmd.Parameters.AddWithValue("JjobID", JobID);
obj_db2.objCmd.Parameters.AddWithValue("@Name", Name);
obj_db2.objCmd.Parameters.AddWithValue("@FName", FatherName);
obj_db2.objCmd.Parameters.AddWithValue("@Email", Email );
obj_db2.objCmd.Parameters.AddWithValue("@Address", Address);
obj_db2.objCmd.Parameters.AddWithValue("@Phone", Phone);
SqlParameter param = new SqlParameter("@AppID", AppID);
param.Direction = ParameterDirection.Output;
param.ParameterName = "@AppID";
param.DbType = DbType.Int32;
obj_db2.objCmd.Parameters.Add(param);
obj_db2.objCmd.ExecuteNonQuery();
}
I have this Function in DAL and i am getting param as output Paramter, I know i can access this AddJobApplication from code behind to enter form information, but not getting the point of how to use this output to insert,, Sorry if i am Taking Very Low Level but i need help.
That really depends on the architecture that’s been established.
If it’s easier, you can probably just return the identity of the new record instead of using an output parameter:
If you’re going to be updating multiple tables though, make sure that it’s all done in the scope of a single transaction.