public static int Update(bPagePhotos objPagePhotos, SqlConnection sqlConn, SqlTransaction sqlTran) { // construct new connection and command objects SqlConnection conn = sqlConn; SqlCommand cmd = DBHelper.getSprocCmd("sprocPagePhotosUpdate", conn); cmd.Transaction = sqlTran; SqlParameter param; // add return value param param = new SqlParameter("@RETURN_VALUE", SqlDbType.Int); param.Direction = ParameterDirection.ReturnValue; cmd.Parameters.Add(param); // add params param = new SqlParameter("@PagePhotoID", SqlDbType.Int); param.Direction = ParameterDirection.Input; param.Value = objPagePhotos.PagePhotoID; cmd.Parameters.Add(param); param = new SqlParameter("@PhotoPath", SqlDbType.VarChar); param.Direction = ParameterDirection.Input; param.Value = objPagePhotos.PhotoPath; cmd.Parameters.Add(param); param = new SqlParameter("@PhotoCaption", SqlDbType.NVarChar); param.Direction = ParameterDirection.Input; param.Value = objPagePhotos.PhotoCaption; cmd.Parameters.Add(param); param = new SqlParameter("@ModifyDate", SqlDbType.DateTime); param.Direction = ParameterDirection.Input; param.Value = objPagePhotos.ModifyDate; cmd.Parameters.Add(param); param = new SqlParameter("@ModifiedBy", SqlDbType.Int); param.Direction = ParameterDirection.Input; param.Value = objPagePhotos.ModifiedBy; cmd.Parameters.Add(param); // open connection conn.Open(); // Execute command cmd.ExecuteNonQuery(); // get return value int retValue = 0; try { // get return value of the sproc retValue = (int)cmd.Parameters["@RETURN_VALUE"].Value; } catch (System.Exception) { // catch all possible exceptions retValue = 0; // set retValue To 0 (all ok) } // close connection conn.Close(); return(retValue); }
public static int Delete(bPagePhotos objPagePhotos) { // construct new connection and command objects SqlConnection conn = DBHelper.getConnection(); SqlCommand cmd = DBHelper.getSprocCmd("sprocPagePhotosDelete", conn); SqlParameter param; // add return value param param = new SqlParameter("@RETURN_VALUE", SqlDbType.Int); param.Direction = ParameterDirection.ReturnValue; cmd.Parameters.Add(param); // Add params param = new SqlParameter("@PagePhotoID", SqlDbType.Int); param.Direction = ParameterDirection.Input; param.Value = objPagePhotos.PagePhotoID; cmd.Parameters.Add(param); // open connection conn.Open(); // Execute command cmd.ExecuteNonQuery(); // get return value int retValue = 0; try { // get return value of the sproc retValue = (int)cmd.Parameters["@RETURN_VALUE"].Value; } catch (System.Exception) { // catch all possible exceptions retValue = 0; // set retValue To 0 (all ok) } // close connection conn.Close(); return(retValue); }